-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.prod.js
110 lines (107 loc) · 2.6 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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
/* eslint-disable prop-types */
const HtmlWebpackPlugin = require('html-webpack-plugin');
const FaviconsWebpackPlugin = require('favicons-webpack-plugin');
const webpack = require('webpack');
const path = require('path');
const WebpackMd5Hash = require('webpack-md5-hash');
const CleanWebpackPlugin = require('clean-webpack-plugin');
// the path(s) that should be cleaned
const pathsToClean = [
'dist/*.*',
];
// the clean options to use
const cleanOptions = {
verbose: true,
dry: false,
};
module.exports = {
devtool: 'cheap-module-source-map',
entry: {
main: ['./src/index.jsx'],
vendor: './src/assets/js/autotrack.js',
},
output: {
path: path.resolve(__dirname, 'dist'),
filename: '[name]-[chunkhash].js',
chunkFilename: '[name]-[chunkhash].js',
publicPath: '/',
},
module: {
rules: [
{
test: /\.jsx?$/,
exclude: /(node_modules)/,
use: 'babel-loader',
},
{
test: /\.css|.sass$/,
use: [
{
loader: 'style-loader',
},
{
loader: 'css-loader',
},
{
loader: 'postcss-loader',
},
{
loader: 'sass-loader',
},
],
},
{
test: /\.(?:png|jpg|svg)$/,
loader: 'url-loader',
query: {
// Inline images smaller than 30kb as data URIs
limit: 30000,
},
},
{
test: /\.((ttf|eot)(\?v=[0-9]\.[0-9]\.[0-9]))|(ttf|eot)$/,
loader: 'file-loader',
},
],
},
resolve: {
extensions: ['.js', '.jsx'],
},
plugins: [
new webpack.DefinePlugin({
'process.env.NODE_ENV': JSON.stringify('production')
}),
new CleanWebpackPlugin(pathsToClean, cleanOptions),
new HtmlWebpackPlugin({ template: './src/index.html' }),
new webpack.NamedModulesPlugin(),
new webpack.NoEmitOnErrorsPlugin(),
new webpack.optimize.CommonsChunkPlugin({
name: 'vendor',
filename: '[name]-[chunkhash].js',
minChunks: Infinity,
}),
new WebpackMd5Hash(),
new FaviconsWebpackPlugin({
logo: './src/assets/icons/favicon.png',
prefix: 'icons-[hash]/',
emitStats: false,
statsFilename: 'iconstats-[hash].json',
persistentCache: true,
inject: true,
background: '#fff',
title: 'Chatmate',
icons: {
android: true,
appleIcon: true,
appleStartup: true,
coast: false,
favicons: true,
firefox: true,
opengraph: true,
twitter: false,
yandex: false,
windows: false,
},
}),
],
};