-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwebpack.config.js
More file actions
99 lines (94 loc) · 2.21 KB
/
webpack.config.js
File metadata and controls
99 lines (94 loc) · 2.21 KB
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
'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');
const production = process.env.NODE_ENV === 'production';
const apiURL = process.env.API_URL || 'http://localhost:3000';
let plugins = [
new ExtractText('bundle.css'),
new webpack.DefinePlugin({
__API_URL__: JSON.stringify(apiURL),
'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV || 'development')
}),
];
if (production) {
plugins = plugins.concat([
new webpack.optimize.UglifyJsPlugin({
mangle: true,
compress: {
warnings: false
}
}),
new CleanPlugin()
]);
}
module.exports = {
entry: [
'./src/index.js'
],
plugins: plugins,
debug: !production,
devtool: production ? false : 'eval',
output: {
path:`${ __dirname}/build`,
filename: 'bundle.js'
},
sassLoader: {
includePaths: [`${__dirname}/src/scss/bootstrap`]
},
postcss: function(){
return [autoprefixer];
},
module: {
loaders: [
{
test: /\.scss$/,
loader: ExtractText.extract('style', 'css!postcss!sass')
},
{
test: /\js$/,
exclude: /node_modules/,
loader: 'babel',
query: {
presets: ['react', 'es2015', 'stage-1']
}
},
{
test: /\.html$/,
loader: 'html'
},
{
test: /\.css$/,
loader:'style-loader!css-loader'
},
{
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]'
},
{
test: /\.(jpg|gif|png|jpeg)$/,
loader: 'file?name=/img/[hash].[ext]'
}
]
},
resolve: {
extensions: ['', '.js', '.jsx']
},
devServer: {
historyApiFallback: true
}
};