-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
88 lines (83 loc) · 1.96 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
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
'use strict';
// npm modules
const webpack = require('webpack');
const autoprefixer = require('autoprefixer');
const CleanPlugin = require('clean-webpack-plugin');
const ExtractText = require('extract-text-webpack-plugin');
// module constants
const production = process.env.NODE_ENV === 'production';
const apiURL = process.env.API_URL || 'http://localhost:3000';
// webpack config
var plugins = [
new ExtractText('bundle.css'),
new webpack.DefinePlugin({
__API_URL__: JSON.stringify(apiURL),
}),
];
if (production){
plugins = plugins.concat([
new webpack.optimize.UglifyJsPlugin({
mangle: true,
compress: {
warnings: false,
},
}),
new CleanPlugin(),
]);
}
module.exports = {
entry: `${__dirname}/app/entry.js`,
debug: !production,
devtool: production ? false : 'eval',
plugins: plugins,
output: {
path: 'build',
filename: 'bundle.js',
},
sassLoader: {
includePaths: [`${__dirname}/app/scss/lib`],
},
postcss: function(){
return [autoprefixer];
},
module:{
loaders: [
{
test: /\.scss$/,
loader: ExtractText.extract('style', 'css!postcss!sass!'),
},
{
test: /\.js$/,
loader: 'babel',
exclude: /node_modules/,
query: {
presets: ['es2015'],
},
},
{
test: /\.html$/,
loader: 'html',
},
{
test: /\.(jpg|gif|png)$/,
loader: 'file?name=img/[hash].[ext]',
},
{
test: /\.svg.*/,
loader: 'url?limit=10000&mimetype=image/svg+xml&name=fonts/[name].[ext]',
},
{
test: /\.woff.*/,
loader: 'file?name=fonts/[name].[ext]',
},
{
test: /\.[ot]tf.*/,
loader: 'url?limit=10000&mimetype=application/octet-stream&name=fonts/[name].[ext]',
},
{
test: /\.eot.*/,
loader: 'url?limit=10000&mimetype=application/vnd.ms-fontobject&name=fonts/[name].[ext]',
},
],
},
};