forked from antoinejaussoin/retro-board
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.prod.config.js
79 lines (77 loc) · 2.68 KB
/
webpack.prod.config.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
const path = require('path');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const autoprefixer = require('autoprefixer');
const webpack = require('webpack');
const config = require('./config');
const appVersion = require('./package.json').version;
const languages = require('./app/i18n/languages');
const staticFolder = path.resolve(__dirname, 'assets');
const momentFilter = languages.map(lang => lang.iso).join('|');
module.exports = {
content: __dirname,
entry: [
'./app/index.jsx'
],
output: {
path: staticFolder,
publicPath: '/assets/',
filename: `app.${appVersion}.js`
},
devtool: 'source-map',
resolve: {
extensions: ['', '.js', '.jsx', '.scss'],
modulesDirectories: [
'node_modules',
path.resolve(__dirname, './node_modules')
]
},
module: {
loaders: [
{ test: /\.css$/, loader: 'style!css' },
{ test: /(\.jsx|\.js)$/, loader: 'babel', exclude: /node_modules/ },
{ test: /\.svg$/, loader: 'url?limit=10' },
{ test: /\.png$/, loader: 'url?limit=10000&mimetype=image/png' },
{ test: /\.jpg$/, loader: 'url?limit=10000&mimetype=image/jpeg' },
{ test: /\.json$/, loader: 'json-loader' },
{
test: /(\.scss)$/,
loader: ExtractTextPlugin.extract('style',
'css?sourceMap&modules&importLoaders=1&localIdentName' +
'=[name]__[local]___[hash:base64:5]!postcss!sass?sourceMap!toolbox')
}
]
},
toolbox: {
theme: path.join(__dirname, 'app/theme.scss')
},
postcss: [autoprefixer],
plugins: [
new webpack.ContextReplacementPlugin(/moment[/\\]locale$/, new RegExp(momentFilter)),
new HtmlWebpackPlugin({
filename: 'index.html',
hash: false,
template: 'content/index-prod.html',
inject: true,
appVersion
}),
new ExtractTextPlugin(`style.${appVersion}.css`, { allChunks: true }),
new webpack.DefinePlugin({
'process.env.NODE_ENV': JSON.stringify('production'),
__DEVELOPMENT__: false,
__DEVTOOLS__: false,
__USE_GA__: config.GA_Enabled,
__GA_ID__: `'${config.GA_Tracking_ID}'`
}),
new webpack.ProvidePlugin({
React: 'react'
}),
new webpack.optimize.DedupePlugin(),
new webpack.optimize.OccurenceOrderPlugin(),
new webpack.optimize.UglifyJsPlugin({
compress: {
warnings: false
}
})
]
};