-
Notifications
You must be signed in to change notification settings - Fork 14
/
webpack.dev.config.js
37 lines (34 loc) · 1.21 KB
/
webpack.dev.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
'use strict';
const path = require('path');
const webpackBaseConfig = require('./webpack.config');
// Plugins
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const __PROD__ = process.env.NODE_ENV === 'production';
module.exports =
Object.assign(webpackBaseConfig, {
devtool: 'source-map',
entry: Object.keys(webpackBaseConfig.entry)
.reduce((obj, entryName) => Object.assign(obj, {
[`dist/${entryName}${__PROD__ ? '' : '.min'}`]: webpackBaseConfig.entry[entryName]
}), {}),
module: Object.assign(webpackBaseConfig.module, {
loaders: webpackBaseConfig.module.loaders.map(loaderObj => {
const loaderTestString = loaderObj.test.toString();
if (loaderTestString === /\.(png|ttf)$/.toString()) {
return Object.assign(loaderObj, {
loader: 'file?name=/[hash].[ext]' // Changed to absolute path because css will try to loader assets from url
});
} else {
return loaderObj;
}
})
}),
plugins: webpackBaseConfig.plugins.concat([
new HtmlWebpackPlugin({
chunks: [], // All are added manually to `index.html`
template: './index.html',
inject: 'head'
})
])
});