This repository has been archived by the owner on Jan 14, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.prod.config.js
103 lines (95 loc) · 2.57 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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
/* sources of learning webpack :
*
* http://christianalfoni.github.io/react-webpack-cookbook/Running-a-workflow.html
* https://github.com/petehunt/webpack-howto
*
*/
var path = require('path');
var webpack = require('webpack');
var ExtractTextPlugin = require("extract-text-webpack-plugin")
var AssetsPlugin = require('assets-webpack-plugin');
var BabelPolyfill = require("babel-polyfill");
var config = {
// sourceMaps simplified to a single mapping per line
entry: {
app: [
'babel-polyfill',
'./src/public/client'
]
},
output: {
path: path.join( __dirname, 'dist' ),
filename: 'bundle.[hash].js',
publicPath: '/static/',
},
plugins: [
new webpack.optimize.OccurenceOrderPlugin(),
new webpack.HotModuleReplacementPlugin(),
new webpack.NoErrorsPlugin(),
new AssetsPlugin(),
new ExtractTextPlugin("styles.[chunkhash].css", {
allChunks: true
}),
new webpack.DefinePlugin({
"process.env": {
NODE_ENV: JSON.stringify("production")
}
}),
],
module: {
loaders: [
{
// json files
test: /\.json$/, loader: 'json'
},
{
// js files
test: /\.js$/,
loaders: ['babel'],
exclude: path.join( __dirname, '/node_modules/'),
include: __dirname
},
{
// less files, get extracted
test: /\.less$/,
loader: ExtractTextPlugin.extract('style-loader', '!css-loader!less-loader'),
exclude: path.join( __dirname, '/node_modules/'),
},
{
// images are stored separately
test: /\.(png|jpg)$/,
loader: 'file-loader?name=images/[hash].[ext]',
exclude: [
path.join( __dirname, '/node_modules/'),
path.join(__dirname, '/src/graphics/favicon.png'),
]
},
{
// favicon png is stored with original name
test: /favicon\.png$/,
loader: 'file-loader?name=images/favicon.png',
exclude: path.join( __dirname, '/node_modules/'),
},
{
// svg are optimised then stored separately
test: /\.(svg)$/,
loaders: [ 'file-loader?name=images/[hash].[ext]', 'svgo-loader?useConfig=svgoConfig'],
exclude: path.join( __dirname, '/node_modules/'),
},
],
},
svgoConfig: {
plugins: [
{removeTitle: true},
{convertColors: {shorthex: false}},
{convertPathData: false}
]
},
resolve: {
root: [
path.resolve(path.join( __dirname, 'src')),
path.resolve(path.join( __dirname, 'src/modules')),
]
},
};
module.exports = config;