This repository has been archived by the owner on Sep 28, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
/
webpack.config.js
116 lines (112 loc) · 3.26 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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
/* eslint strict: 0 */
'use strict';
// const ExtractTextPlugin = require('extract-text-webpack-plugin');
const DefinePlugin = require('webpack/lib/DefinePlugin');
const HotModuleReplacementPlugin = require('webpack/lib/HotModuleReplacementPlugin');
const NoErrorsPlugin = require('webpack/lib/NoErrorsPlugin');
const OccurenceOrderPlugin = require('webpack/lib/optimize/OccurenceOrderPlugin');
const path = require('path');
const UglifyJsPlugin = require('webpack/lib/optimize/UglifyJsPlugin');
const WebpackNotifierPlugin = require('webpack-notifier');
const fs = require('fs');
const manifest = JSON.parse(fs.readFileSync(path.join(__dirname, 'app', 'manifest.json')));
const production = Boolean(process.env.PRODUCTION);
const plugins = production ?
[
new OccurenceOrderPlugin(),
new DefinePlugin({
__DEV__: false,
'process.env': {
NODE_ENV: JSON.stringify('production')
},
VERSION: JSON.stringify(manifest.version),
}),
new UglifyJsPlugin({
compressor: {
screw_ie8: true,
warnings: false
}
}),
// new ExtractTextPlugin('style.css', { allChunks: true })
] :
[
new HotModuleReplacementPlugin(),
new NoErrorsPlugin(),
new WebpackNotifierPlugin(),
new DefinePlugin({
__DEV__: true,
'process.env': {
NODE_ENV: JSON.stringify('development')
},
VERSION: JSON.stringify(manifest.version),
})
];
module.exports = {
debug: !production,
devTool: production ? 'source-map' : 'cheap-module-eval-source-map',
entry: {
index: './src/index',
eventPage: './src/eventPage',
},
module: {
loaders: [{
test: /\.jsx?$/,
loaders: ['babel-loader'],
exclude: /node_modules/
}, {
test: /\.json$/,
loader: 'json-loader'
}, {
test: /\.scss$/,
loaders: ['style', 'css?modules', 'sass'],
include: path.resolve(__dirname, './node_modules'),
}, {
test: /\.css$/,
loaders: ['style', 'css?modules'],
include: path.resolve(__dirname, './node_modules'),
}, {
test: /\.woff(2)?(\?v=[0-9]\.[0-9]\.[0-9])?$/,
loader: 'url-loader?limit=10000&mimetype=application/font-woff'
}, {
test: /\.png$/,
loader: 'url-loader?limit=10000&mimetype=application/font-woff'
}, {
test: /\.(ttf|eot|svg)(\?v=[0-9]\.[0-9]\.[0-9])?$/,
loader: 'file-loader'
}, {
test: /\.global\.css$/,
loaders: ['style-loader', 'css-loader'],
exclude: path.resolve(__dirname, './node_modules'),
}, {
test: /^((?!\.global).)*\.css$/,
loaders: [
// ExtractTextPlugin.extract(
'style-loader',
production ?
'css-loader?modules&importLoaders=1&localIdentName=[name]__[local]___[hash:base64:5]' :
'css-loader?modules&sourceMap&importLoaders=1&localIdentName=[name]__[local]___[hash:base64:5]'
],
exclude: path.resolve(__dirname, './node_modules'),
// )
}
]
},
output: {
path: path.join(__dirname, 'app', 'dist'),
filename: '[name].js',
libraryTarget: 'var',
publicPath: './dist/',
},
resolve: {
extensions: ['', '.js', '.jsx', '.scss'],
packageMains: ['webpack', 'browser', 'web', 'browserify', ['jam', 'main'], 'main']
},
node: {
child_process: 'empty',
fs: 'empty',
net: 'empty',
},
plugins,
externals: [
]
};