diff --git a/package.json b/package.json index 0a4d997..5351648 100644 --- a/package.json +++ b/package.json @@ -16,7 +16,7 @@ "clean": "rimraf -rf lib esm dist", "lint-staged": "lint-staged", "test": "jest", - "build:umd": "rimraf ./dist && webpack --config webpack.config.js --mode production && npm run size", + "build:umd": "rimraf ./dist && rollup -c && npm run size", "build:cjs": "rimraf ./lib && tsc --module commonjs --outDir lib", "build:esm": "rimraf ./esm && tsc --module ESNext --outDir esm", "build": "npm run build:cjs && npm run build:esm && npm run build:umd", @@ -36,14 +36,9 @@ "@antplot/graphics" ], "devDependencies": { - "@babel/core": "^7.12.16", - "@babel/plugin-transform-runtime": "^7.12.15", - "@babel/preset-env": "^7.12.16", - "@babel/runtime": "^7.12.13", "@commitlint/cli": "^11.0.0", "@types/jest": "^26.0.20", "@types/lodash": "^4.14.168", - "babel-loader": "^8.2.2", "husky": "^5.0.9", "jest": "^26.6.3", "jest-electron": "^0.1.11", @@ -60,10 +55,7 @@ "ts-jest": "^26.5.1", "ts-loader": "^8.0.17", "ts-node": "^9.1.1", - "typescript": "^4.1.5", - "webpack": "^5.22.0", - "webpack-bundle-analyzer": "^4.4.0", - "webpack-cli": "^4.5.0" + "typescript": "^4.1.5" }, "jest": { "runner": "jest-electron/runner", diff --git a/rollup.config.js b/rollup.config.js index 53386c6..71beed0 100644 --- a/rollup.config.js +++ b/rollup.config.js @@ -10,7 +10,11 @@ module.exports = [{ name: 'Graphics', format: 'umd', sourcemap: false, + globals: { + lodash: '_', + }, }, + external:['lodash'], plugins: [ resolve(), typescript(), diff --git a/webpack.config.js b/webpack.config.js deleted file mode 100644 index 58303c8..0000000 --- a/webpack.config.js +++ /dev/null @@ -1,79 +0,0 @@ -const webpack = require('webpack'); -const resolve = require('path').resolve; -const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin; - -const BABEL_OPTIONS = { - presets: [ - [ - '@babel/preset-env', - { - targets: '> 0.25%, not dead', - }, - ], - ], - plugins: [ - [ - '@babel/transform-runtime', - { - helpers: false, - regenerator: true, - }, - ], - ], -}; - -module.exports = { - entry: { - graphics: './src/index.ts', - }, - output: { - filename: '[name].min.js', - library: 'Graphics', - libraryTarget: 'umd', - path: resolve(__dirname, 'dist/'), - }, - externals: { - lodash: '_', - }, - resolve: { - mainFields: ['module', 'main'], - extensions: ['.ts', '.js', '.less'], - }, - module: { - rules: [ - { - test: /\.ts$/, - use: [ - { - loader: 'babel-loader', - options: BABEL_OPTIONS, - }, - { - loader: 'ts-loader', - options: { - transpileOnly: true, - }, - }, - ] - }, - { - test: /\.js$/, - /** bable 只需要处理 node_modules 中的 es6 模块,src 中的交给 ts-loader 即可 */ - include: /node_modules/, - use: { - loader: 'babel-loader', - options: BABEL_OPTIONS, - }, - }, - ], - }, - plugins: [ - new webpack.NoEmitOnErrorsPlugin(), - new webpack.optimize.AggressiveMergingPlugin(), - ...(process.env.MODE === 'ANALYZER' ? [new BundleAnalyzerPlugin({ analyzerMode: 'static' })] : []), - ], - performance: { - hints: false, - }, - devtool: 'source-map', -};