-
Notifications
You must be signed in to change notification settings - Fork 2
/
webpack.prod.config.js
83 lines (76 loc) · 2.14 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
/* global __dirname */
var config = require('./webpack.config.js');
var path = require('path');
var BundleTracker = require('webpack-bundle-tracker');
var ExtractTextPlugin = require('extract-text-webpack-plugin');
var webpack = require('webpack');
// Remove webpack-dev-server
config.debug = false;
config.devtool = 'source-map';
config.entry = {
main: './../velafrica/frontend/static/js/main.js',
styles: './../velafrica/frontend/static/scss/main.scss',
};
config.module.loaders = [
{
test: /\.jsx?$/,
//exclude: /node_modules/,
//use include instead of exclude, so foundation will be babelized too before
//uflifying, which then solves the problem
//see https://webpack.github.io/docs/configuration.html#module-loaders
include: [
// path.resolve(__dirname, 'app/static'),
// path.resolve(__dirname, 'assets/js'),
// path.resolve(__dirname, 'node_modules/foundation-sites/js'),
],
loader: 'babel',
query: {
presets: ['es2015'],
cacheDirectory: path.resolve(__dirname, 'tmp'),
},
},
{
test: /\.css$/,
loader: ExtractTextPlugin.extract('style', 'css'),
},
{
test: /\.scss$/,
loader: ExtractTextPlugin.extract('style', 'css!postcss!sass'),
},
{
test: /\.less/,
loader: ExtractTextPlugin.extract('style', 'css!less?relative-urls'),
},
{
test: /\.(png|woff2?|svg|eot|ttf)$/,
loader: 'url-loader?limit=20000',
},
{
test: /\.(jpg)$/,
loader: 'file?relative-urls',
},
];
config.output = {
path: path.resolve('./staticfiles/dist/'),
publicPath: '/static/dist/',
filename: '[name]-[hash].js',
};
config.plugins = [
new BundleTracker({filename: './tmp/webpack-stats-prod.json'}),
new ExtractTextPlugin('[name]-[hash].css', {allChunks: true}),
// removes a lot of debugging code in react
new webpack.DefinePlugin({
'process.env': {
'NODE_ENV': JSON.stringify('production'),
},
}),
// keeps hashes consistent between compilations
new webpack.optimize.OccurenceOrderPlugin(),
// minifies your code
new webpack.optimize.UglifyJsPlugin({
compressor: {
warnings: false,
},
}),
];
module.exports = config;