-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwebpack.config.production.js
More file actions
executable file
·132 lines (123 loc) · 3.04 KB
/
Copy pathwebpack.config.production.js
File metadata and controls
executable file
·132 lines (123 loc) · 3.04 KB
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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
// Webpack config for creating the production bundle.
var path = require('path')
var webpack = require('webpack')
var CleanPlugin = require('clean-webpack-plugin')
var ExtractTextPlugin = require('extract-text-webpack-plugin')
var AssetsPlugin = require('assets-webpack-plugin')
var relativeOutputPath = './build/static/dist'
var outputPath = path.join(__dirname, relativeOutputPath)
module.exports = {
target: 'web',
devtool: 'source-map',
entry: {
'main': './src/client/main.production.js'
},
output: {
path: outputPath,
filename: '[name]-[hash].js',
chunkFilename: '[name]-[id]-[chunkhash].js',
publicPath: '/dist/'
},
module: {
rules: [{
test: /\.js$/,
exclude: path.join(__dirname, 'node_modules'),
use: [{
loader: 'babel-loader'
}]
}, {
test: /\.html$/,
exclude: path.join(__dirname, 'node_modules'),
use: [{
loader: 'html-loader'
}]
}, {
test: /\.ya?ml$/,
exclude: path.join(__dirname, 'node_modules'),
use: [{
loader: 'json-loader'
}, {
loader: 'yaml-loader'
}]
}, {
test: /\.css$/,
exclude: path.join(__dirname, 'node_modules'),
use: ExtractTextPlugin.extract({
fallback: 'style-loader',
use: [{
loader: 'css-loader',
options: {
importLoaders: 1
}
}, {
loader: 'postcss-loader'
}]
})
}, {
test: /\.(jpe?g|png|gif)$/i,
use: [{
loader: 'url-loader',
options: {
limit: 10000,
hash: 'sha512',
digest: 'hex',
name: '[hash].[ext]'
}
}]
}, {
test: /\.woff(2)?(\?.*)?$/,
use: [{
loader: 'url-loader',
options: {
limit: 10000,
minetype: 'application/font-woff'
}
}]
}, {
test: /\.(ttf|eot|svg)(\?.*)?$/,
use: [{
loader: 'file-loader'
}]
}]
},
resolve: {
modules: [
'src/client',
'node_modules'
],
extensions: ['.json', '.js'],
alias: {
'socket.io-client': 'socket.io-client/dist/socket.io.js'
}
},
plugins: [
new CleanPlugin([relativeOutputPath]),
new webpack.ProvidePlugin({
riot: 'riot'
}),
// css files from the extract-text-plugin loader
new ExtractTextPlugin('[name]-[hash].css'),
new webpack.DefinePlugin({
__DEVELOPMENT__: false,
APP_NAME: 'heu-rs-form'
}),
// ignore dev config
new webpack.IgnorePlugin(/\.\/dev/, /\/config$/),
// set global vars
new webpack.DefinePlugin({
'process.env': {
// Useful to reduce the size of client-side libraries, e.g. react
NODE_ENV: JSON.stringify('production')
}
}),
// optimizations
new webpack.optimize.CommonsChunkPlugin({name: 'commons', filename: 'commons-[hash].js'}),
new webpack.optimize.UglifyJsPlugin({
compress: {
warnings: false
}
}),
// assets in json file
new AssetsPlugin({filename: 'webpack-assets.json'})
]
}