umd build

This commit is contained in:
AllenFang 2018-01-14 23:43:21 +08:00
parent 3a8390c49e
commit ec705f2651
4 changed files with 104 additions and 1 deletions

2
.gitignore vendored
View File

@ -20,4 +20,4 @@ yarn-error.log*
storybook-static
# build
lib
dist

29
build.js Normal file
View File

@ -0,0 +1,29 @@
/* eslint no-console: 0 */
import rimraf from 'rimraf';
import * as path from 'path';
import webpack from 'webpack';
import config from './webpack.prod.config.babel';
const build = () => {
[
path.join(__dirname, 'packages/react-bootstrap-table2/dist'),
path.join(__dirname, 'packages/react-bootstrap-table2-editor/dist'),
path.join(__dirname, 'packages/react-bootstrap-table2-filter/dist'),
path.join(__dirname, 'packages/react-bootstrap-table2-overlay/dist'),
path.join(__dirname, 'packages/react-bootstrap-table2-paginator/dist')
].forEach((dir) => {
rimraf.sync(dir);
});
webpack(config).run((err) => {
if (err) {
console.error('Failed to compile.', [err]);
process.exit(1);
} else {
console.info('Compiled successfully');
}
});
};
build();

View File

@ -6,6 +6,7 @@
"scripts": {
"postinstall": "lerna bootstrap",
"publish": "lerna run build && lerna publish --silent",
"build": "node -r babel-register build.js",
"start": "node -r babel-register ./node_modules/.bin/webpack-dev-server --config webpack.config.babel.js",
"lint": "eslint ./packages --ext .js --ext .jsx --ignore-path .gitignore",
"pretest": "yarn lint --cache",

View File

@ -0,0 +1,73 @@
import * as path from 'path';
import webpack from 'webpack';
const sourceStylePath = path.join(__dirname, 'packages/react-bootstrap-table2/style');
const paginationSourceStylePath = path.join(__dirname, 'packages/react-bootstrap-table2-paginator/style');
module.exports = {
entry: {
'react-bootstrap-table2/dist/react-bootstrap-table2': ['./packages/react-bootstrap-table2'],
'react-bootstrap-table2/dist/react-bootstrap-table2.min': ['./packages/react-bootstrap-table2'],
'react-bootstrap-table2-editor/dist/react-bootstrap-table2-editor': ['./packages/react-bootstrap-table2-editor'],
'react-bootstrap-table2-editor/dist/react-bootstrap-table2-editor.min': ['./packages/react-bootstrap-table2-editor'],
'react-bootstrap-table2-filter/dist/react-bootstrap-table2-filter': ['./packages/react-bootstrap-table2-filter'],
'react-bootstrap-table2-filter/dist/react-bootstrap-table2-filter.min': ['./packages/react-bootstrap-table2-filter'],
'react-bootstrap-table2-overlay/dist/react-bootstrap-table2-overlay': ['./packages/react-bootstrap-table2-overlay'],
'react-bootstrap-table2-overlay/dist/react-bootstrap-table2-overlay.min': ['./packages/react-bootstrap-table2-overlay'],
'react-bootstrap-table2-paginator/dist/react-bootstrap-table2-paginator': ['./packages/react-bootstrap-table2-paginator'],
'react-bootstrap-table2-paginator/dist/react-bootstrap-table2-paginator.min': ['./packages/react-bootstrap-table2-paginator']
},
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/,
// include: [sourcePath],
loader: 'eslint-loader'
}, {
test: /\.js?$/,
use: ['babel-loader'],
exclude: /node_modules/
// include: [sourcePath]
}, {
test: /\.scss$/,
use: ['style-loader', 'css-loader', 'sass-loader'],
include: [sourceStylePath, paginationSourceStylePath]
}]
},
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 }
})
]
};