-
Notifications
You must be signed in to change notification settings - Fork 1
/
webpack-production.config.js
75 lines (72 loc) · 1.71 KB
/
webpack-production.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
const webpack = require('webpack');
const path = require('path');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const config = {
entry: {
main: [
'./src/main.js',
],
},
// output config
output: {
path: path.resolve(__dirname, 'lib'), // Path of output file
filename: 'build/[name].js', // Name of output file
},
resolve: {
modules: [path.resolve(__dirname, "src"), "node_modules"]
},
plugins: [
// Define production build to allow React to strip out unnecessary checks
new webpack.DefinePlugin({
'process.env':{
'NODE_ENV': JSON.stringify('production')
}
}),
// Minify the bundle
new webpack.optimize.UglifyJsPlugin(),
new webpack.optimize.OccurrenceOrderPlugin(),
new webpack.optimize.AggressiveMergingPlugin(),
// remove useless locales that moment automatically bundles
new webpack.IgnorePlugin(/^\.\/locale$/, /moment$/),
new ExtractTextPlugin('build/[name].css'),
],
module: {
rules: [
{
test: /\.(pdf|jpg|png|gif|svg|ico|otf)$/,
use: [
{
loader: 'file-loader',
options: {
name: '[path][name]-[hash:8].[ext]'
}
}
]
},
{
test: /\.svg\.inline$/,
use: {
loader: 'svg-inline-loader',
},
},
{
test: /\.s?css$/,
use: ExtractTextPlugin.extract({
use: [
{loader: "css-loader"},
{loader: "sass-loader"},
]
}),
},
{
test: /\.js$/,
exclude: /node_modules/,
loader: 'babel-loader',
query: {
cacheDirectory: true,
},
},
],
},
};
module.exports = config;