-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwebpack.config.js
More file actions
113 lines (100 loc) · 2.5 KB
/
webpack.config.js
File metadata and controls
113 lines (100 loc) · 2.5 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
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
const path = require('path');
const webpack = require('webpack');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const postcss = require('./src/postcss');
const isProduction = process.env.NODE_ENV === 'production';
const cssLoader = `css-loader?${JSON.stringify({
sourceMap: !isProduction,
minimize: false,
})}`;
const entry = path.join(__dirname, 'src', 'index');
const config = {
entry: isProduction ? [
// 'babel-polyfill',
entry,
] : [
'webpack-hot-middleware/client',
entry,
],
output: {
path: path.join(__dirname, 'assets'),
filename: 'application.js',
publicPath: '/assets/',
pathinfo: !isProduction,
},
resolve: {
root: path.join(__dirname, 'src'),
},
plugins: [
new webpack.DefinePlugin({
'process.env': {
NODE_ENV: JSON.stringify(isProduction ? 'production' : 'development'),
},
}),
new webpack.ProvidePlugin({
_: 'underscore',
}),
new ExtractTextPlugin('application.css'),
new HtmlWebpackPlugin({
filename: 'index_en.html',
lang: 'en',
template: path.join(__dirname, 'src', 'index.ejs'),
}),
new HtmlWebpackPlugin({
filename: 'index_ru.html',
lang: 'ru',
template: path.join(__dirname, 'src', 'index.ejs'),
}),
],
module: {
loaders: [
{
test: /\.(jpg|png|gif|ico)$/,
loader: 'file-loader?name=[name].[ext]',
},
{
test: /\.json$/,
loader: 'json-loader',
},
{
test: /\.ejs$/,
loader: 'ejs-loader',
},
{
test: /\.(js|es6)$/,
exclude: /node_modules/,
loader: 'babel-loader',
},
{
test: /\.css$/,
loader: ExtractTextPlugin.extract('style-loader', [cssLoader, 'postcss-loader?pack=vendor']),
},
{
test: /\.pcss$/,
loader: ExtractTextPlugin.extract('style-loader', [cssLoader, 'postcss-loader']),
},
],
},
devtool: isProduction ? 'source-map' : '#eval-source-map',
postcss,
};
if (isProduction) {
config.plugins.push(
new webpack.NoErrorsPlugin(),
new webpack.optimize.UglifyJsPlugin({
compressor: {
warnings: false,
},
screw_ie8: true,
}),
new webpack.optimize.DedupePlugin(),
new webpack.optimize.OccurenceOrderPlugin(true)
);
} else {
config.plugins.push(
new webpack.HotModuleReplacementPlugin(),
new webpack.NoErrorsPlugin()
);
}
module.exports = config;