forked from microsoft/fluentui
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.demo.config.js
89 lines (74 loc) · 1.86 KB
/
webpack.demo.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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
'use strict';
/** Note: this require may need to be fixed to point to the build that exports the gulp-core-build-webpack instance. */
let webpackTaskResources = require('web-library-build').webpack.resources;
let webpack = webpackTaskResources.webpack;
let path = require('path');
var SplitByPathPlugin = require('webpack-split-by-path');
// Create an array of configs, prepopulated with a debug (non-minified) build.
let configs = [
createConfig(false)
];
// Create a production config if applicable.
if (process.argv.indexOf('--production') > -1) {
configs.push(createConfig(true));
}
// Helper to create the config.
function createConfig(isProduction) {
let minFileNamePart = isProduction ? '.min' : '';
let webpackConfig = {
context: path.join(__dirname, '/lib'),
entry: {
'demo-app': './demo/app.js'
},
output: {
path: path.join(__dirname, '/dist'),
filename: `[name]${ minFileNamePart }.js`,
chunkFilename: `[name]${ minFileNamePart }.js`
},
devtool: 'source-map',
devServer: {
stats: 'none'
},
externals: [
{
'react': 'React'
},
{
'react-dom': 'ReactDOM'
},
],
module: {
noParse: [/autoit.js/],
preLoaders: [
{
test: /\.js$/,
loader: "source-map-loader"
}
],
loaders: [
]
},
plugins: [
new SplitByPathPlugin([
{
name: 'demo-vendor',
path: path.join(__dirname, 'node_modules'),
},
{
name: 'demo-components',
path: path.join(__dirname, 'lib', 'components')
}
])
]
};
if (isProduction) {
webpackConfig.plugins.push(new webpack.optimize.UglifyJsPlugin({
minimize: true,
compress: {
warnings: false
}
}));
}
return webpackConfig;
}
module.exports = configs;