-
Notifications
You must be signed in to change notification settings - Fork 147
/
webpack.config.babel.js
93 lines (83 loc) · 1.99 KB
/
webpack.config.babel.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
import webpack from 'webpack';
import ExtractTextPlugin from 'extract-text-webpack-plugin';
import HtmlWebpackPlugin from 'html-webpack-plugin';
import autoprefixer from 'autoprefixer';
const ENV = process.env.NODE_ENV || 'development';
module.exports = {
entry: './demo/index.js',
output: {
path: './build',
publicPath: '/',
filename: 'bundle.js'
},
resolve: {
extensions: ['', '.jsx', '.js', '.json', '.styl']
},
module: {
preLoaders: [
{
test: /\.jsx?$/,
exclude: /src\//,
loader: 'source-map'
}
],
loaders: [
{
test: /\.jsx?$/,
exclude: /node_modules/,
loader: 'babel'
},
{
test: /\.(styl|css)$/,
loader: ExtractTextPlugin.extract('css?sourceMap!postcss!stylus?sourceMap')
},
{
test: /\.json$/,
loader: 'json'
},
{
test: /\.(xml|html|txt)$/,
loader: 'raw'
},
{
test: /\.(svg|woff|ttf|eot)(\?.*)?$/i,
loader: 'file-loader?name=assets/fonts/[name]_[hash:base64:5].[ext]'
}
]
},
postcss: () => [
autoprefixer({ browsers: 'last 2 versions' })
],
plugins: ([
new webpack.NoErrorsPlugin(),
new ExtractTextPlugin('style.css', { allChunks: true }),
new webpack.DefinePlugin({
'process.env.NODE_ENV': JSON.stringify(ENV)
}),
new HtmlWebpackPlugin({
title: 'Fancy Autocomplete - Preact + Redux + Animate.css',
template: 'demo/index.ejs',
})
]).concat(ENV==='production' ? [
new webpack.optimize.DedupePlugin(),
new webpack.optimize.OccurenceOrderPlugin()
] : []),
stats: { colors: true },
devtool: ENV==='production' ? 'source-map' : 'inline-source-map',
devServer: {
port: process.env.PORT || 8080,
host: '0.0.0.0',
colors: true,
publicPath: '/',
contentBase: './demo',
historyApiFallback: true,
proxy: [
// OPTIONAL: proxy configuration:
// {
// path: '/optional-prefix/**',
// target: 'http://target-host.com',
// rewrite: req => { req.url = req.url.replace(/^\/[^\/]+\//, ''); } // strip first path segment
// }
]
}
};