-
Notifications
You must be signed in to change notification settings - Fork 5
/
webpack.config.prod.js
76 lines (75 loc) · 1.7 KB
/
webpack.config.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
const webpack = require('webpack');
const path = require('path');
const StyleLintPlugin = require('stylelint-webpack-plugin');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const StatsPlugin = require('stats-webpack-plugin');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
module.exports = {
entry: [path.join(__dirname, '/src/app/entry.js')],
output: {
path: path.resolve(__dirname, './dist'),
filename: '[name]-[hash].min.js',
publicPath: '/',
},
mode: 'production',
resolve: {},
plugins: [
new MiniCssExtractPlugin({
filename: '[name].css',
chunkFilename: '[id].css',
}),
new HtmlWebpackPlugin({
template: 'src/app/index.tpl.html',
inject: 'body',
filename: 'index.html',
favicon: './src/app/assets/images/my_logo.png',
}),
new webpack.NoEmitOnErrorsPlugin(),
new webpack.DefinePlugin({
'process.env.NODE_ENV': JSON.stringify('development'),
}),
new StatsPlugin('webpack.stats.json', {
source: false,
modules: false,
}),
new StyleLintPlugin(),
],
module: {
rules: [
{
test: /(\.js$|\.jsx$)/,
exclude: /node_modules/,
use: [
{
loader: 'babel-loader',
options: {
presets: ['@babel/preset-react', '@babel/preset-env'],
},
},
],
},
{
test: /\.png$/,
use: 'url-loader?lmit=1000&mimetype=image/png',
},
{
test: /\.(jpg|png|gif|eot|svg|ttf|woff|woff2)$/,
use: 'file-loader',
},
{
test: /\.(mp4|webm)$/,
use: 'url-loader?limit=10000',
},
{
test: /(\.scss$|\.css$)/,
use: [
process.env.NODE_ENV !== 'production'
? 'style-loader'
: MiniCssExtractPlugin.loader,
'css-loader',
'sass-loader',
],
},
],
},
};