-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathwebpack.prod.js
82 lines (80 loc) · 2.06 KB
/
webpack.prod.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
/**
* To spot diffs between dev and prod configs - some diff tool meant to be used.
* vs code: explorer - right click on file - select for compare
*/
const path = require('path')
const webpack = require('webpack')
const CleanWebpackPlugin = require('clean-webpack-plugin')
const CopyWebpackPlugin = require('copy-webpack-plugin')
const HtmlWebpackPlugin = require('html-webpack-plugin')
module.exports = {
context: __dirname,
devtool: 'source-map',
entry: './src/frontend/js/index.js',
output: {
path: path.join(__dirname, '/dist'),
filename: 'bundle.[hash].js',
publicPath: '/',
},
module: {
rules: [
{
test: /\.js$/,
exclude: /node_modules/,
loader: 'babel-loader',
options: {
'babelrc': false,
'presets': [
['react'],
['env'],
],
'plugins': [
'transform-class-properties',
'transform-object-rest-spread',
]
},
},
{
test: /\.less$/,
exclude: /node_modules/,
use: [
{ loader: 'style-loader' },
{ loader: 'css-loader' },
{ loader: 'postcss-loader' },
{ loader: 'less-loader' },
]
},
{
test: /\.woff$/,
loader: 'file-loader',
options: { name: 'fonts/[name].[ext]' },
},
{
test: /\.(jpg|png|svg|gif)$/,
loader: 'file-loader',
options: { name: 'img/[name].[ext]' },
},
]
},
plugins: [
new CleanWebpackPlugin(['dist']),
new CopyWebpackPlugin([
{ from: './src/frontend/img/content', to: 'img/content' },
{ from: './src/frontend/favicon.ico' },
{ from: './src/frontend/service-worker.js' },
]),
new HtmlWebpackPlugin({
template: './src/frontend/index.html',
}),
new webpack.LoaderOptionsPlugin({
minimize: true,
debug: false,
}),
new webpack.optimize.UglifyJsPlugin({
sourceMap: true,
}),
new webpack.DefinePlugin({
'process.env.NODE_ENV': JSON.stringify('production'),
}),
],
}