forked from gtoma4/react-verto-communicator
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwebpack.config.js
More file actions
71 lines (69 loc) · 1.84 KB
/
webpack.config.js
File metadata and controls
71 lines (69 loc) · 1.84 KB
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
var path = require('path');
var webpack = require('webpack');
var CopyWebpackPlugin = require('copy-webpack-plugin');
var config = {
entry: {
app: path.resolve(__dirname, './src/main.js'),
vendors: ['react','react-dom']
},
output: {
path: './src',
filename: 'bundle.js'
},
devServer: {
inline: true,
contentBase: './src',
port: 8080
},
module: {
loaders: [
{
test: /\.js$/,
exclude: /node_modules/,
loaders: ["react-hot", "babel?presets[]=es2015&presets[]=stage-0&presets[]=react"]
}
]
},
plugins: [
new webpack.optimize.OccurenceOrderPlugin(true),
new webpack.optimize.DedupePlugin(),
new webpack.optimize.CommonsChunkPlugin('vendors', 'vendors.js')
]
}
console.log('---> ', process.env.NODE_ENV );
//export NODE_ENV=production
// unset NODE_ENV
if (process.env.NODE_ENV === 'production') {
config.output.path = path.join(__dirname, 'dist/')
config.plugins.push(new webpack.optimize.UglifyJsPlugin({
output: {
comments: false
},
compress: {
warnings: false,
screw_ie8: true
}
}));
config.plugins.push(new webpack.DefinePlugin({
'process.env': {
'NODE_ENV': '"production"'
}
}));
config.plugins.push(new CopyWebpackPlugin([
// {output}/file.txt
//{ from: 'messages', to: 'messages' },
{ from: 'src/index.html', to: 'index.html' },
{ from: 'src/css', to: 'css'},
{ from: 'src/img', to: 'img' },
{ from: 'images', to: 'img' },
{ from: 'src/locales', to: 'locales'},
{ from: 'src/3rd-party', to: '3rd-party'},
{ from: 'src/favicon.ico', to: 'favicon.ico' }
], {
ignore: [
// Doesn't copy any files with a txt extension
'*.txt'
]
}));
}
module.exports = config