-
Notifications
You must be signed in to change notification settings - Fork 1
/
webpack.config.js
78 lines (74 loc) · 1.78 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
/**
* Created by ash on 11/05/2017.
*/
const path = require('path');
const webpack = require('webpack');
const WebpackDevServer = require('webpack-dev-server');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const exec = require('child_process').exec;
const config = {
context: path.join(__dirname, '/example'),
entry: './index.jsx',
devtool: 'source-map',
watchOptions: { poll: true },
output: {
filename: 'bundle.js',
publicPath: '/',
path: __dirname + '/public/',
},
module: {
loaders: [
{
test: /\.(css|scss)$/,
loader: ExtractTextPlugin.extract(['css', 'sass']),
},
{
test: /\.(woff|woff2|eot|ttf|svg)(\?\S*)?$/,
loader: 'url?limit=100000&font/name=[name].[ext]',
},
{
test: /\.ico$/,
loader:'file-loader?name=[name].ico',
exclude: /node_modules/,
},
{
test: /\.jsx$/,
loaders: ['jsx?harmony', 'babel'],
exclude: /node_modules/,
},
{
test: /\.html$/,
loader: 'file-loader?name=[name].[ext]',
exclude: /node_modules/,
}]
},
resolve: {
root: [path.resolve(__dirname, ''), path.resolve(__dirname, 'node_modules')],
extensions: ['', '.js', '.jsx', '.png']
},
plugins: [
new ExtractTextPlugin('styles.css', {allChunks: true}),
new webpack.NoErrorsPlugin(),
]
};
let compiler = webpack(config);
exec('gulp');
let server = new WebpackDevServer(compiler, {
contentBase: './public',
quiet: false,
lazy: false,
stats: {
colors: true,
},
proxy: {
'**': {
secure: false,
bypass(req, res, proxyOptions) {
if (req.headers.accept.indexOf('html') !== -1) {
return '/index.html';
}
},
},
},
});
server.listen(8033);