-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprod.config.js
More file actions
114 lines (110 loc) · 2.81 KB
/
Copy pathprod.config.js
File metadata and controls
114 lines (110 loc) · 2.81 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
var path = require('path')
var webpack = require('webpack')
var ExtractTextPlugin = require('extract-text-webpack-plugin')
var ChunkManifestPlugin = require('chunk-manifest-webpack-plugin')
var WebpackMd5Hash = require('webpack-md5-hash') //required for ChunkManifestPlugin to work
var ManifestPlugin = require('webpack-manifest-plugin')
const ROOT = '../..'
// const VERSION = require(ROOT + '/package.json').version || '0.0.0'
var configVars = {
NODE_ENV: JSON.stringify('production'),
BROWSER: JSON.stringify(true)
}
const config = require(ROOT + '/config/config.js')['production']
// const { STATIC_URL } = config
module.exports = {
context: path.resolve(__dirname, ROOT),
entry: {
main: './src/client',
vendor: [
'babel-polyfill',
'lodash',
'react',
'react-dom',
"react-helmet",
'redux',
'redux-thunk',
'react-redux',
'react-router',
'react-router-scroll',
]
},
output: {
path: path.join(__dirname, ROOT + '/build'),
publicPath: '/',
filename: 'js/[name]_[chunkhash]_bundle.js',
chunkFilename: 'js/[name]_[chunkhash]_chunk.js'
},
resolve: {
alias: {
Src: path.join(__dirname, ROOT + '/src'),
Config: path.join(__dirname, ROOT + '/config'),
},
extensions: ['.js', '.jsx']
},
plugins: [
new webpack.LoaderOptionsPlugin({
minimize: true,
debug: false,
options: {
postcss: [
require('postcss-cssnext'),
require('lost'),
require('postcss-assets')({
basePath: 'static/',
baseUrl: config['STATIC_URL'] + '/'
})
]
}
}),
new webpack.DefinePlugin({
'process.env': configVars
}),
new webpack.optimize.UglifyJsPlugin({
compress: {
warnings: false,
dead_code: true,
unused: true,
},
output: {
comments: false
},
sourceMap: false,
}),
new webpack.optimize.CommonsChunkPlugin({
name: 'vendor',
filename: 'js/vendor_[chunkhash]_bundle.js',
minChunks: Infinity
}),
new webpack.optimize.MinChunkSizePlugin({
minChunkSize: 50000
}),
new WebpackMd5Hash(),
new ChunkManifestPlugin({
filename: 'chunk-manifest.json',
manifestVariable: 'webpackManifest'
}),
new ManifestPlugin(),
new ExtractTextPlugin('css/main_[contenthash].css'),
],
module: {
rules: [
{
test: /\.js$/,
use: {
loader: 'babel-loader',
options: Object.assign({ babelrc: false }, require('./prod.babelrc.js'))
},
exclude: /node_modules/,
},
{
test: /\.scss$/,
use: ExtractTextPlugin.extract('css-loader!postcss-loader!sass-loader')
},
{
test: /\.woff2?$/,
loader: 'url-loader'
},
]
},
}