forked from mozilla/donate.mozilla.org
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
52 lines (51 loc) · 1.64 KB
/
webpack.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
require('habitat').load();
var webpack = require('webpack');
var Path = require('path');
var ExtractTextPlugin = require("extract-text-webpack-plugin");
var AssetsPlugin = require('assets-webpack-plugin');
var WebpackOnBuildPlugin = require('on-build-webpack');
module.exports = {
entry: ['./dist/client.js','./less/index.less'],
output: {
filename: '[name].[hash].js',
chunkFilename: '[id].chunk.js',
path: Path.join( __dirname, './public')
},
resolve: {
extensions: ['.js']
},
module: {
rules: [
{ test: /\.json$/, loader: 'json-loader', exclude: ['node_modules'] },
{ test: /\.jsx$/, enforce: 'pre', loader: 'eslint-loader', exclude: ['node_modules'] },
{
test: /\.less$/,
use: ExtractTextPlugin.extract({
fallback: 'style-loader',
use: ['css-loader', 'less-loader']
})
}
]
},
plugins: [
new AssetsPlugin({
path: Path.join(__dirname, 'public')
}),
new webpack.ProvidePlugin({
'fetch': 'imports-loader?this=>global!exports-loader?global.fetch!whatwg-fetch'
}),
new ExtractTextPlugin("style.[hash].css", {
allChunks: true
}),
new WebpackOnBuildPlugin(function(stats) {
console.log('\n------------------------------------------');
console.log(' Build complete. To access the server,');
console.log(' open http://' + process.env.HOST + ':' + process.env.PORT, 'in a browser.');
console.log('------------------------------------------');
}),
new webpack.DefinePlugin({
'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV)
}),
new webpack.optimize.UglifyJsPlugin()
]
};