-
Notifications
You must be signed in to change notification settings - Fork 20
/
webpack.prod.config.js
48 lines (43 loc) · 1.43 KB
/
webpack.prod.config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
const webpack = require('webpack');
const path = require('path');
const merge = require('webpack-merge');
const commonConfiguration = require('./webpack.common.config');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const UglifyJsPlugin = require('uglifyjs-webpack-plugin')
const outputPath = path.join(__dirname, 'build', 'lib');
const filename = 'react-input-trigger';
const libraryName = 'ReactInputTrigger';
const production = JSON.stringify('production');
const devtool = 'source-map'; // original source - for use in production
const externals = { react: 'react' };
const definePlugin = new webpack.DefinePlugin({ 'process.env.NODE_ENV': production });
const uglifyPlugin = new UglifyJsPlugin();
const libraryConfiguration = merge(commonConfiguration, {
devtool,
output: {
path: outputPath,
filename: '[name].js',
libraryTarget: 'commonjs2',
},
externals,
plugins: [uglifyPlugin, definePlugin],
});
const docsConfiguration = merge.strategy({ entry: 'replace' })(commonConfiguration, {
entry: { app: path.resolve(__dirname, 'src', 'docs', 'index.js'), },
context: path.resolve(__dirname, 'src', 'docs'),
output: {
path: path.resolve(__dirname, 'docs'),
publicPath: './',
filename: '[name].[chunkhash:5].js',
},
plugins: [
new HtmlWebpackPlugin({ template: './index.html' }),
definePlugin,
uglifyPlugin,
],
devtool,
});
module.exports = [
libraryConfiguration,
docsConfiguration,
];