From b172c6801c3775eff3ed40c4e0960faf96a34eba Mon Sep 17 00:00:00 2001 From: Allen Date: Sun, 8 Apr 2018 21:17:24 +0800 Subject: [PATCH] fix #228 --- gulpfile.babel.js | 12 +++++-- webpack.prod.config.babel.js | 64 ---------------------------------- webpack/editor.umd.babel.js | 16 +++++++++ webpack/filter.umd.babel.js | 16 +++++++++ webpack/next.umd.babel.js | 16 +++++++++ webpack/overlay.umd.babel.js | 16 +++++++++ webpack/paginator.umd.babel.js | 16 +++++++++ webpack/webpack.umd.babel.js | 45 ++++++++++++++++++++++++ 8 files changed, 134 insertions(+), 67 deletions(-) delete mode 100644 webpack.prod.config.babel.js create mode 100644 webpack/editor.umd.babel.js create mode 100644 webpack/filter.umd.babel.js create mode 100644 webpack/next.umd.babel.js create mode 100644 webpack/overlay.umd.babel.js create mode 100644 webpack/paginator.umd.babel.js create mode 100644 webpack/webpack.umd.babel.js diff --git a/gulpfile.babel.js b/gulpfile.babel.js index 77b5c9f..f202fda 100644 --- a/gulpfile.babel.js +++ b/gulpfile.babel.js @@ -72,9 +72,15 @@ function styles() { .pipe(gulp.dest(PKG_PATH)); } -function umd() { - return gulp.src('./webpack.prod.config.babel.js') - .pipe(shell(['webpack --config <%= file.path %>'])); +function umd(done) { + gulp.parallel( + () => gulp.src('./webpack/next.umd.babel.js').pipe(shell(['webpack --config <%= file.path %>'])), + () => gulp.src('./webpack/editor.umd.babel.js').pipe(shell(['webpack --config <%= file.path %>'])), + () => gulp.src('./webpack/filter.umd.babel.js').pipe(shell(['webpack --config <%= file.path %>'])), + () => gulp.src('./webpack/overlay.umd.babel.js').pipe(shell(['webpack --config <%= file.path %>'])), + () => gulp.src('./webpack/paginator.umd.babel.js').pipe(shell(['webpack --config <%= file.path %>'])) + )(); + done(); } const buildJS = gulp.parallel(umd, scripts); diff --git a/webpack.prod.config.babel.js b/webpack.prod.config.babel.js deleted file mode 100644 index 6a69ac0..0000000 --- a/webpack.prod.config.babel.js +++ /dev/null @@ -1,64 +0,0 @@ -import * as path from 'path'; -import webpack from 'webpack'; - -module.exports = { - entry: { - 'react-bootstrap-table2/dist/react-bootstrap-table2': './packages/react-bootstrap-table2/index.js', - 'react-bootstrap-table2/dist/react-bootstrap-table2.min': './packages/react-bootstrap-table2/index.js', - 'react-bootstrap-table2-editor/dist/react-bootstrap-table2-editor': './packages/react-bootstrap-table2-editor/index.js', - 'react-bootstrap-table2-editor/dist/react-bootstrap-table2-editor.min': './packages/react-bootstrap-table2-editor/index.js', - 'react-bootstrap-table2-filter/dist/react-bootstrap-table2-filter': './packages/react-bootstrap-table2-filter/index.js', - 'react-bootstrap-table2-filter/dist/react-bootstrap-table2-filter.min': './packages/react-bootstrap-table2-filter/index.js', - 'react-bootstrap-table2-overlay/dist/react-bootstrap-table2-overlay': './packages/react-bootstrap-table2-overlay/index.js', - 'react-bootstrap-table2-overlay/dist/react-bootstrap-table2-overlay.min': './packages/react-bootstrap-table2-overlay/index.js', - 'react-bootstrap-table2-paginator/dist/react-bootstrap-table2-paginator': './packages/react-bootstrap-table2-paginator/index.js', - 'react-bootstrap-table2-paginator/dist/react-bootstrap-table2-paginator.min': './packages/react-bootstrap-table2-paginator/index.js' - }, - devtool: 'source-map', - output: { - path: path.join(__dirname, 'packages'), - filename: '[name].js', - library: 'ReactBootstrapTable', - libraryTarget: 'umd' - }, - externals: [{ - 'react': { - root: 'React', - commonjs2: 'react', - commonjs: 'react', - amd: 'react' - } - }, { - 'react-dom': { - root: 'ReactDOM', - commonjs2: 'react-dom', - commonjs: 'react-dom', - amd: 'react-dom' - } - }], - module: { - rules: [{ - enforce: 'pre', - test: /\.js?$/, - exclude: /node_modules/, - loader: 'eslint-loader' - }, { - test: /\.js?$/, - use: ['babel-loader'], - exclude: /node_modules/ - }] - }, - plugins: [ - new webpack.DefinePlugin({ - 'process.env.NODE_ENV': JSON.stringify('production') - }), - new webpack.SourceMapDevToolPlugin(), - new webpack.optimize.DedupePlugin(), - new webpack.optimize.OccurrenceOrderPlugin(), - new webpack.optimize.AggressiveMergingPlugin(), - new webpack.optimize.UglifyJsPlugin({ - include: /\.min\.js$/, - compress: { warnings: false } - }) - ] -}; diff --git a/webpack/editor.umd.babel.js b/webpack/editor.umd.babel.js new file mode 100644 index 0000000..c1ad1d6 --- /dev/null +++ b/webpack/editor.umd.babel.js @@ -0,0 +1,16 @@ +import * as path from 'path'; +import umdConfig from './webpack.umd.babel'; + +module.exports = { + ...umdConfig, + entry: { + 'react-bootstrap-table2-editor/dist/react-bootstrap-table2-editor': './packages/react-bootstrap-table2-editor/index.js', + 'react-bootstrap-table2-editor/dist/react-bootstrap-table2-editor.min': './packages/react-bootstrap-table2-editor/index.js' + }, + output: { + path: path.join(__dirname, '../packages'), + filename: '[name].js', + library: 'ReactBootstrapTable2Editor', + libraryTarget: 'umd' + } +}; diff --git a/webpack/filter.umd.babel.js b/webpack/filter.umd.babel.js new file mode 100644 index 0000000..c69c278 --- /dev/null +++ b/webpack/filter.umd.babel.js @@ -0,0 +1,16 @@ +import * as path from 'path'; +import umdConfig from './webpack.umd.babel'; + +module.exports = { + ...umdConfig, + entry: { + 'react-bootstrap-table2-filter/dist/react-bootstrap-table2-filter': './packages/react-bootstrap-table2-filter/index.js', + 'react-bootstrap-table2-filter/dist/react-bootstrap-table2-filter.min': './packages/react-bootstrap-table2-filter/index.js' + }, + output: { + path: path.join(__dirname, '../packages'), + filename: '[name].js', + library: 'ReactBootstrapTable2Filter', + libraryTarget: 'umd' + } +}; diff --git a/webpack/next.umd.babel.js b/webpack/next.umd.babel.js new file mode 100644 index 0000000..c2071f0 --- /dev/null +++ b/webpack/next.umd.babel.js @@ -0,0 +1,16 @@ +import * as path from 'path'; +import umdConfig from './webpack.umd.babel'; + +module.exports = { + ...umdConfig, + entry: { + 'react-bootstrap-table2/dist/react-bootstrap-table-next': './packages/react-bootstrap-table2/index.js', + 'react-bootstrap-table2/dist/react-bootstrap-table-next.min': './packages/react-bootstrap-table2/index.js' + }, + output: { + path: path.join(__dirname, '../packages'), + filename: '[name].js', + library: 'ReactBootstrapTable2', + libraryTarget: 'umd' + } +}; diff --git a/webpack/overlay.umd.babel.js b/webpack/overlay.umd.babel.js new file mode 100644 index 0000000..ac6d198 --- /dev/null +++ b/webpack/overlay.umd.babel.js @@ -0,0 +1,16 @@ +import * as path from 'path'; +import umdConfig from './webpack.umd.babel'; + +module.exports = { + ...umdConfig, + entry: { + 'react-bootstrap-table2-overlay/dist/react-bootstrap-table2-overlay': './packages/react-bootstrap-table2-overlay/index.js', + 'react-bootstrap-table2-overlay/dist/react-bootstrap-table2-overlay.min': './packages/react-bootstrap-table2-overlay/index.js' + }, + output: { + path: path.join(__dirname, '../packages'), + filename: '[name].js', + library: 'ReactBootstrapTable2Overlay', + libraryTarget: 'umd' + } +}; diff --git a/webpack/paginator.umd.babel.js b/webpack/paginator.umd.babel.js new file mode 100644 index 0000000..1779447 --- /dev/null +++ b/webpack/paginator.umd.babel.js @@ -0,0 +1,16 @@ +import * as path from 'path'; +import umdConfig from './webpack.umd.babel'; + +module.exports = { + ...umdConfig, + entry: { + 'react-bootstrap-table2-paginator/dist/react-bootstrap-table2-paginator': './packages/react-bootstrap-table2-paginator/index.js', + 'react-bootstrap-table2-paginator/dist/react-bootstrap-table2-paginator.min': './packages/react-bootstrap-table2-paginator/index.js' + }, + output: { + path: path.join(__dirname, '../packages'), + filename: '[name].js', + library: 'ReactBootstrapTable2Paginator', + libraryTarget: 'umd' + } +}; diff --git a/webpack/webpack.umd.babel.js b/webpack/webpack.umd.babel.js new file mode 100644 index 0000000..31a6cdc --- /dev/null +++ b/webpack/webpack.umd.babel.js @@ -0,0 +1,45 @@ +import webpack from 'webpack'; + +module.exports = { + devtool: 'source-map', + externals: [{ + 'react': { + root: 'React', + commonjs2: 'react', + commonjs: 'react', + amd: 'react' + } + }, { + 'react-dom': { + root: 'ReactDOM', + commonjs2: 'react-dom', + commonjs: 'react-dom', + amd: 'react-dom' + } + }], + module: { + rules: [{ + enforce: 'pre', + test: /\.js?$/, + exclude: /node_modules/, + loader: 'eslint-loader' + }, { + test: /\.js?$/, + use: ['babel-loader'], + exclude: /node_modules/ + }] + }, + plugins: [ + new webpack.DefinePlugin({ + 'process.env.NODE_ENV': JSON.stringify('production') + }), + new webpack.SourceMapDevToolPlugin(), + new webpack.optimize.DedupePlugin(), + new webpack.optimize.OccurrenceOrderPlugin(), + new webpack.optimize.AggressiveMergingPlugin(), + new webpack.optimize.UglifyJsPlugin({ + include: /\.min\.js$/, + compress: { warnings: false } + }) + ] +};