forked from CenterForCollectiveLearning/DIVE-frontend
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
82 lines (79 loc) · 2.9 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
var path = require('path');
var webpack = require('webpack');
var ExtractTextPlugin = require('extract-text-webpack-plugin');
var CopyWebpackPlugin = require('copy-webpack-plugin');
var host = '0.0.0.0';
var port = 3009;
var devFlagPlugin = new webpack.DefinePlugin({
__DEV__: JSON.stringify(JSON.parse(process.env.DEBUG || 'false'))
});
function getEntrySources(sources) {
sources.push(`webpack-dev-server/client?http://${ host }:${ port }`)
sources.push('webpack/hot/only-dev-server')
return sources;
}
module.exports = {
cache: true,
devtool: 'source-map',
quiet: false,
stats: {
// Config for minimal console.log mess.
assets: false,
colors: true,
version: false,
hash: false,
timings: false,
chunks: false,
chunkModules: false
},
entry: getEntrySources([
'./src/js/index.js',
'./src/css/app.css'
]),
output: {
path: path.join(__dirname, '/dist'),
publicPath: '/',
filename: 'bundle.js',
hot: true
},
plugins: [
new webpack.HotModuleReplacementPlugin(),
new webpack.NoErrorsPlugin(),
devFlagPlugin,
new ExtractTextPlugin('app.css'),
new webpack.ProvidePlugin({
Promise: 'imports?this=>global!exports?global.Promise!es6-promise',
fetch: 'imports?this=>global!exports?global.fetch!whatwg-fetch'
}),
new CopyWebpackPlugin([
{ from: './src/index.html', to: './index.html' },
{ from: './src/404.html', to: './404.html' },
{ from: './src/assets', to: './assets'},
{ from: './_redirects' }
])
],
module: {
noParse: /node_modules\/quill\/dist/,
loaders: [
{ test: require.resolve("react"), loader: "imports?shim=es6-shim/es6-shim&sham=es6-shim/es6-sham" },
{ test: /\.js$/, loader: 'babel',
cacheDirectory: true,
include: [ path.join(__dirname, 'src/js') ],
exclude: /node_modules/ },
{ test: /\.css$/, loader: ExtractTextPlugin.extract('css-loader?module!cssnext-loader') },
{ test: /\.sass$/, loader: 'style!css?modules&importLoaders=2&sourceMap&localIdentName=[local]___[hash:base64:5]!autoprefixer?browsers=last 2 version!sass?indentedSyntax&outputStyle=expanded&sourceMap' },
{ test: /\.less$/, loader: "style!css!less" },
{ test: /\.woff(2)?(\?v=[0-9]\.[0-9]\.[0-9])?$/, loader: "url?limit=10000&minetype=application/font-woff" },
{ test: /\.(ttf|eot|ttf)(\?v=[0-9]\.[0-9]\.[0-9])?$/, loader: "file" },
{ test: /\.svg(\?.*)?$/, loader: 'babel!svg-react' +
// removes xmlns tag from svg (see https://github.com/jhamlet/svg-react-loader/issues/25)
'!string-replace?search=%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22&replace=' +
// removes data-name attributes
'!string-replace?search=%20data-name%3D%22%5B%5Cw%5Cs_-%5D*%22&replace=&flags=ig' },
{ test: /\.png$/, loader: "url-loader?mimetype=image/png" },
]
},
resolve: {
extensions: ['', '.js', '.json']
}
};