-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.production.config.js
82 lines (81 loc) · 2.07 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
76
77
78
79
80
81
82
var webpack = require('webpack');
var path = require('path');
var CopyWebpackPlugin = require('copy-webpack-plugin');
var UglifyJsPlugin = require('uglifyjs-webpack-plugin');
module.exports = {
devtool: 'cheap-source-map',
entry: [
path.resolve(__dirname, 'app/main.jsx'),
],
output: {
path: __dirname + '/build',
publicPath: '/',
filename: './bundle.js'
},
context: path.resolve(__dirname + '/app/assets'),
module: {
rules:[
{
test: /\.css$/,
include: path.resolve(__dirname, 'app'),
use: [
'style-loader',
{
loader: 'css-loader',
options: {
modules: true,
localIdentName: '[path][name]__[local]--[hash:base64:5]'
}
}
]
},
{
test: /\.js[x]?$/,
include: path.resolve(__dirname, 'app'),
exclude: /node_modules/,
use: 'babel-loader'
}, {
test: /\.(svg|m4v)$/,
loader: 'file-loader'
}, {
test: /\.(jpg|png|ico|gif)$/,
loader: 'url-loader',
options: {
fallback: 'file-loader',
limit: 25000
}
}
// {
// // match image files
// test: /\.(jpe?g|png|svg|gif|ico)$/,
//
// // match one of the loader's main parameters (sizes and placeholder)
// // resourceQuery: /[?&](sizes|placeholder)(=|&|\[|$)/,
//
// use: [
// 'svg-loader',
// // any other loader
// 'file-loader?hash=sha512&digest=hex&name=[hash].[ext]',
// ],
// }
]
},
resolve: {
extensions: ['.js', '.jsx'],
},
plugins: [
new UglifyJsPlugin({
sourceMap: true
}),
new webpack.DefinePlugin({
'process.env': {
NODE_ENV: JSON.stringify('production')
}
}),
new CopyWebpackPlugin([
{ from: './app/index.html', to: 'index.html', context: path.resolve(__dirname) },
{ from: './app/main.css', to: 'main.css', context: path.resolve(__dirname) },
{ from: 'favicons', to: 'favicons' },
]),
]
};