update: remove siroc and use rollup directly
* add rollup.config.js
This commit is contained in:
+14
-9
@@ -8,12 +8,6 @@
|
|||||||
},
|
},
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"author": "Burak Cakmakoglu",
|
"author": "Burak Cakmakoglu",
|
||||||
"exports": {
|
|
||||||
".": {
|
|
||||||
"import": "./dist/index.js",
|
|
||||||
"require": "./dist/index.js"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"main": "dist/RevueFlow.js",
|
"main": "dist/RevueFlow.js",
|
||||||
"module": "dist/RevueFlow.esm.js",
|
"module": "dist/RevueFlow.esm.js",
|
||||||
"types": "dist/index.d.ts",
|
"types": "dist/index.d.ts",
|
||||||
@@ -24,9 +18,9 @@
|
|||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "vite",
|
"dev": "vite",
|
||||||
"build": "vue-tsc --noEmit && vite build",
|
"build": "vue-tsc --noEmit && vite build",
|
||||||
"build:siroc": "siroc build",
|
"build:dist": "rollup -c --environment NODE_ENV:production && postcss src/*.css --dir dist",
|
||||||
"serve": "vite preview",
|
"serve": "vite preview",
|
||||||
"prepublishOnly": "yarn build:siroc",
|
"prepublishOnly": "yarn build:dist",
|
||||||
"test": "exit 0"
|
"test": "exit 0"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
@@ -35,6 +29,12 @@
|
|||||||
"vue": "^3.0.5"
|
"vue": "^3.0.5"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
"@babel/core": "^7.14.6",
|
||||||
|
"@rollup/plugin-babel": "^5.3.0",
|
||||||
|
"@rollup/plugin-commonjs": "^19.0.0",
|
||||||
|
"@rollup/plugin-node-resolve": "^13.0.0",
|
||||||
|
"@rollup/plugin-replace": "^2.4.2",
|
||||||
|
"@svgr/rollup": "^5.5.0",
|
||||||
"@types/d3": "^7.0.0",
|
"@types/d3": "^7.0.0",
|
||||||
"@typescript-eslint/eslint-plugin": "^4.28.1",
|
"@typescript-eslint/eslint-plugin": "^4.28.1",
|
||||||
"@typescript-eslint/parser": "^4.28.1",
|
"@typescript-eslint/parser": "^4.28.1",
|
||||||
@@ -55,7 +55,12 @@
|
|||||||
"postcss-cli": "^8.3.1",
|
"postcss-cli": "^8.3.1",
|
||||||
"postcss-nested": "^5.0.5",
|
"postcss-nested": "^5.0.5",
|
||||||
"prettier": "^2.2.1",
|
"prettier": "^2.2.1",
|
||||||
"siroc": "^0.12.0",
|
"rollup-plugin-bundle-size": "^1.0.3",
|
||||||
|
"rollup-plugin-postcss": "^4.0.0",
|
||||||
|
"rollup-plugin-typescript2": "^0.30.0",
|
||||||
|
"rollup": "^2.52.2",
|
||||||
|
"rollup-plugin-livereload": "^2.0.0",
|
||||||
|
"rollup-plugin-serve": "^1.1.0",
|
||||||
"typescript": "^4.3.5",
|
"typescript": "^4.3.5",
|
||||||
"vite": "^2.3.8",
|
"vite": "^2.3.8",
|
||||||
"vue-tsc": "^0.0.24"
|
"vue-tsc": "^0.0.24"
|
||||||
|
|||||||
@@ -0,0 +1,75 @@
|
|||||||
|
import resolve from '@rollup/plugin-node-resolve';
|
||||||
|
import commonjs from '@rollup/plugin-commonjs';
|
||||||
|
import babel from '@rollup/plugin-babel';
|
||||||
|
import postcss from 'rollup-plugin-postcss';
|
||||||
|
import bundleSize from 'rollup-plugin-bundle-size';
|
||||||
|
import replace from '@rollup/plugin-replace';
|
||||||
|
import svgr from '@svgr/rollup';
|
||||||
|
import typescript from 'rollup-plugin-typescript2';
|
||||||
|
import { DEFAULT_EXTENSIONS as DEFAULT_BABEL_EXTENSIONS } from '@babel/core';
|
||||||
|
|
||||||
|
import pkg from './package.json';
|
||||||
|
|
||||||
|
const isProd = process.env.NODE_ENV === 'production';
|
||||||
|
const isTesting = process.env.NODE_ENV === 'testing';
|
||||||
|
const processEnv = isProd || isTesting ? 'production' : 'development';
|
||||||
|
|
||||||
|
export const baseConfig = ({ mainFile = pkg.main, moduleFile = pkg.module, injectCSS = true } = {}) => ({
|
||||||
|
input: 'src/index.ts',
|
||||||
|
external: ['react', 'react-dom', (id) => id.includes('@babel/runtime')],
|
||||||
|
onwarn(warning, rollupWarn) {
|
||||||
|
if (warning.code !== 'CIRCULAR_DEPENDENCY') {
|
||||||
|
rollupWarn(warning);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
output: [
|
||||||
|
{
|
||||||
|
file: mainFile,
|
||||||
|
format: 'cjs',
|
||||||
|
sourcemap: true,
|
||||||
|
exports: 'named'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
file: moduleFile,
|
||||||
|
format: 'esm',
|
||||||
|
sourcemap: true,
|
||||||
|
exports: 'named'
|
||||||
|
}
|
||||||
|
],
|
||||||
|
plugins: [
|
||||||
|
replace({
|
||||||
|
__ENV__: JSON.stringify(processEnv),
|
||||||
|
__REACT_FLOW_VERSION__: JSON.stringify(pkg.version),
|
||||||
|
preventAssignment: true
|
||||||
|
}),
|
||||||
|
bundleSize(),
|
||||||
|
postcss({
|
||||||
|
minimize: isProd,
|
||||||
|
inject: injectCSS
|
||||||
|
}),
|
||||||
|
svgr(),
|
||||||
|
resolve(),
|
||||||
|
typescript({
|
||||||
|
clean: true
|
||||||
|
}),
|
||||||
|
commonjs({
|
||||||
|
include: 'node_modules/**'
|
||||||
|
}),
|
||||||
|
babel({
|
||||||
|
extensions: [...DEFAULT_BABEL_EXTENSIONS, '.ts', '.tsx'],
|
||||||
|
exclude: 'node_modules/**',
|
||||||
|
babelHelpers: 'inline'
|
||||||
|
})
|
||||||
|
]
|
||||||
|
});
|
||||||
|
|
||||||
|
export default isProd && !isTesting
|
||||||
|
? [
|
||||||
|
baseConfig(),
|
||||||
|
baseConfig({
|
||||||
|
mainFile: 'dist/nocss/ReactFlow-nocss.js',
|
||||||
|
moduleFile: 'dist/nocss/ReactFlow-nocss.esm.js',
|
||||||
|
injectCSS: false
|
||||||
|
})
|
||||||
|
]
|
||||||
|
: baseConfig();
|
||||||
@@ -1,65 +0,0 @@
|
|||||||
import {defineSirocConfig} from 'siroc'
|
|
||||||
import resolve from '@rollup/plugin-node-resolve';
|
|
||||||
import commonjs from '@rollup/plugin-commonjs';
|
|
||||||
import babel from '@rollup/plugin-babel';
|
|
||||||
import postcss from 'rollup-plugin-postcss';
|
|
||||||
import bundleSize from 'rollup-plugin-bundle-size';
|
|
||||||
import replace from '@rollup/plugin-replace';
|
|
||||||
import svgr from '@svgr/rollup';
|
|
||||||
import typescript from 'rollup-plugin-typescript2';
|
|
||||||
import {DEFAULT_EXTENSIONS as DEFAULT_BABEL_EXTENSIONS} from '@babel/core';
|
|
||||||
|
|
||||||
import pkg from './package.json';
|
|
||||||
|
|
||||||
const isProd = process.env.NODE_ENV === 'production';
|
|
||||||
const isTesting = process.env.NODE_ENV === 'testing';
|
|
||||||
const processEnv = isProd || isTesting ? 'production' : 'development';
|
|
||||||
export default defineSirocConfig({
|
|
||||||
rollup: {
|
|
||||||
input: 'src/index.ts',
|
|
||||||
onwarn(warning, rollupWarn) {
|
|
||||||
if (warning.code !== 'CIRCULAR_DEPENDENCY') {
|
|
||||||
rollupWarn(warning);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
output: [
|
|
||||||
{
|
|
||||||
file: mainFile,
|
|
||||||
format: 'cjs',
|
|
||||||
sourcemap: true,
|
|
||||||
exports: 'named',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
file: moduleFile,
|
|
||||||
format: 'esm',
|
|
||||||
sourcemap: true,
|
|
||||||
exports: 'named',
|
|
||||||
},
|
|
||||||
],
|
|
||||||
plugins: [
|
|
||||||
replace({
|
|
||||||
__ENV__: JSON.stringify(processEnv),
|
|
||||||
__REACT_FLOW_VERSION__: JSON.stringify(pkg.version),
|
|
||||||
preventAssignment: true,
|
|
||||||
}),
|
|
||||||
bundleSize(),
|
|
||||||
postcss({
|
|
||||||
minimize: isProd,
|
|
||||||
inject: injectCSS,
|
|
||||||
}),
|
|
||||||
svgr(),
|
|
||||||
resolve(),
|
|
||||||
typescript({
|
|
||||||
clean: true,
|
|
||||||
}),
|
|
||||||
commonjs({
|
|
||||||
include: 'node_modules/**',
|
|
||||||
}),
|
|
||||||
babel({
|
|
||||||
extensions: [...DEFAULT_BABEL_EXTENSIONS, '.ts', '.tsx'],
|
|
||||||
exclude: 'node_modules/**',
|
|
||||||
babelHelpers: 'runtime',
|
|
||||||
}),
|
|
||||||
],
|
|
||||||
}
|
|
||||||
})
|
|
||||||
Reference in New Issue
Block a user