-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js.orig
executable file
·112 lines (104 loc) · 2.53 KB
/
webpack.config.js.orig
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
var path = require('path');
var webpack = require('webpack');
var NpmInstallPlugin = require('npm-install-webpack-plugin');
var autoprefixer = require('autoprefixer');
var Clean = require('clean-webpack-plugin');
var precss = require('precss');
var ExtractTextPlugin = require('extract-text-webpack-plugin');
var PROD = process.env.NODE_ENV === 'production';
var TEST = JSON.parse(process.env.TEST || "0");
//Если потребуется в скриптах/модулях знать в каком режиме работает приложение, то можно использовать переменную PROD
var definePlugin = new webpack.DefinePlugin({
PROD: PROD,
TEST: TEST,
'process.env': {
NODE_ENV: PROD ? '"production"' : '"development"'
}
});
var entry = [
'webpack-hot-middleware/client?reload=true',
'babel-polyfill',
'./src/index.js'
];
var plugins = [
new ExtractTextPlugin(
"styles.css",
{
allChunks: true
}
),
new webpack.optimize.OccurenceOrderPlugin(),
new webpack.HotModuleReplacementPlugin(),
new webpack.NoErrorsPlugin(),
new NpmInstallPlugin(),
definePlugin
];
if (PROD) {
entry = ['./src/index.js'];
plugins.push(
new webpack.optimize.UglifyJsPlugin({
mangle: false,
minimize: true,
output: {comments: false},
warnings: false,
drop_console: true,
unsafe: true
})
);
plugins.push(new Clean(['build']));
}
module.exports = {
devtool: PROD ? null : 'cheap-inline-module-source-map',
entry: entry,
output: {
path: __dirname + '/build',
filename: 'bundle.js',
publicPath: '/static/'
},
plugins: plugins,
module: {
preLoaders: [
{
test: /\.js$/,
loaders: ['eslint'],
exclude: /(node_modules)/,
include: [
path.resolve(__dirname, "src")
]
}
],
loaders: [
{
loaders: ['react-hot', 'babel-loader'],
include: [
path.resolve(__dirname, "src")
],
test: /\.js$/,
exclude: /(node_modules)/,
plugins: ['transform-runtime']
},
{
test: /\.less$/,
exclude: /(node_modules)/,
loader: ExtractTextPlugin.extract(
'style?sourceMap',
'css?sourceMap&modules&importLoaders=1&localIdentName=' + (process.env.NODE_ENV === 'development' ? '[path]__[local]___[hash:base64:5]' : '[hash:base64:10]'),
'resolve-url',
'postcss-loader?sourceMap',
'less?sourceMap'
)
},
{
test: /\.css$/,
plugins: ['transform-runtime'],
loaders: [ 'style', 'css?sourceMap' ]
}
]
},
postcss: function () {
return [autoprefixer, precss];
},
resolve: {
modulesDirectories: ['node_modules']
}
};