-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathwebpack.config.js
83 lines (75 loc) · 2 KB
/
webpack.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
const fs = require('fs');
const path = require('path');
const _ = require('lodash');
const webpack = require('webpack');
const nodeExternals = require('webpack-node-externals');
const LodashModule = require('lodash-webpack-plugin');
const dev = process.env.NODE_ENV === 'dev';
/**
* Base Webpack Config
*/
const base = {
entry: {
'semantic-ui-redux-form-fields': path.resolve(__dirname, './lib/index.js')
},
devtool: dev ? '#eval-source-map' : 'source-map',
output: {
path: path.resolve(__dirname, './dist'),
filename: '[name].js',
library: '[name]',
libraryTarget: 'umd'
},
module: {
loaders: [{
test: /\.js$/,
exclude: /node_modules/,
loaders: ['babel-loader']
}]
},
plugins: dev ? [
new webpack.NoEmitOnErrorsPlugin(),
new webpack.LoaderOptionsPlugin({debug: true})
] : [
new webpack.optimize.OccurrenceOrderPlugin(true),
// Appends eslint-disable
new webpack.BannerPlugin({
banner: '\n\n/* eslint-disable */\n',
raw: true
}),
//reduces module size
new LodashModule(),
// Appends the License into the library builds
new webpack.BannerPlugin(fs.readFileSync(path.join(process.cwd(), './LICENSE.txt'), 'utf8')),
new webpack.LoaderOptionsPlugin({
minimize: true,
debug: false
})
]
};
/**
* Node Build
*/
const node = _.defaultsDeep({}, base);
node.target = 'node';
node.externals = [nodeExternals()];
/**
* Web Build
*/
const web = _.defaultsDeep({}, base);
web.target = 'web';
web.output.filename = '[name]-browser.js';
/**
* Web Min Build
*/
const webMin = _.defaultsDeep({}, base);
webMin.target = 'web';
webMin.output.filename = '[name]-browser.min.js';
if (!dev) {
webMin.plugins.push(new webpack.optimize.UglifyJsPlugin());
}
module.exports = dev
? [web]
:
// Remove or comment out if you do not want
// webpack to build a specific version
[node, webMin, web];