-
Notifications
You must be signed in to change notification settings - Fork 67
/
Copy pathwebpack.config.js
91 lines (84 loc) · 2.02 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
/* eslint-disable */
const webpack = require('webpack');
const RemoveWebpackPlugin = require('remove-webpack-plugin');
const autoprefixer = require('autoprefixer');
const precss = require('precss');
const atImport = require("postcss-import");
const easyImport = require('postcss-easy-import');
const postCssModules = require('postcss-modules');
const postCssLoader = [
'css-loader?modules',
'&importLoaders=1',
'&localIdentName=[name]__[local]___[hash:base64:5]',
'&disableStructuralMinification',
'!postcss-loader'
];
module.exports = {
entry: {
'index': "./src/index.jsx"
},
output: {
path: './build',
filename: "[name].js"
},
plugins: [
new RemoveWebpackPlugin('./build', 'hide'),
new webpack.NoErrorsPlugin(),
new webpack.optimize.DedupePlugin(),
new webpack.optimize.UglifyJsPlugin({
compress: {
warnings: false,
drop_console: true,
unsafe: true
}
})
],
resolve: {
moduleDirectories: ['node_modules'],
extensions: ['', '.js', '.jsx']
},
resolveLoader: {
moduleDirectories: ['node_modules'],
moduleTemplates: ['*-loader', '*'],
extensions: ['', '.js', '.jsx']
},
module: {
loaders: [
{
test: /\.jsx$/, loader: "babel-loader", exclude: [/node_modules/, /lib/]
},
{
test: /\.js$/, loader: "babel-loader", exclude: [/node_modules/, /lib/]
},
{
test: /\.css$/,
loader: postCssLoader.join('')
}, {
test: /\.png$/,
loader: "file-loader?name=/images/[hash].[ext]"
}, {
test: /\.jpg$/,
loader: "file-loader?name=/images/[hash].[ext]"
}, {
test: /\.gif$/,
loader: "file-loader?name=/images/[hash].[ext]"
}, {
test: /\.(ttf|eot|svg|woff(2)?)(\?[a-z0-9]+)?$/,
loader: 'file-loader?name=/fonts/[hash].[ext]'
}
]
},
postcss: function() {
return [
atImport({
plugins: [easyImport],
}),
postCssModules({
scopeBehaviour: 'global',
generateScopedName: '[name]__[local]___[hash:base64:5]',
}),
autoprefixer,
precss()
];
}
};