forked from abukurov/hwdtech-card
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.dev.config.js
89 lines (76 loc) · 1.99 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
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
/* eslint-env node */
const map = require('lodash/map');
const path = require('path');
const webpack = require('webpack');
const autoprefixer = require('autoprefixer');
const HtmlPlugin = require('html-webpack-plugin');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const CopyPlugin = require('copy-webpack-plugin');
const devPort = 3000;
const profileConfigs = require('require-all')({
dirname: __dirname + '/config',
filter: /(.+)\.js$/,
recursive: true
});
module.exports = {
devServer: {
hot: true,
port: devPort
},
devtool: 'eval',
entry: [
`webpack-dev-server/client?http://localhost:${devPort}`,
'webpack/hot/only-dev-server',
path.join(__dirname, 'assets/main.js')
],
output: {
path: path.join(__dirname, 'dist'),
filename: 'bundle.js'
},
module: {
loaders: [{
test: /\.js$/,
exclude: /node_modules/,
loader: 'babel?cacheDirectory'
}, {
test: /\.pug/,
loader: 'pug'
}, {
test: /\.scss$/,
loader: ExtractTextPlugin.extract('style-loader', ['css', 'postcss', 'sass'])
}, {
test: /\.(jpe?g|png|gif|svg|ico)$/,
loader: 'file',
query: {
name: 'images/[hash].[ext]'
}
}, {
test: /\.woff$/,
loader: 'url',
query: {
name: 'font/[hash].[ext]',
limit: 5000,
mimetype: 'application/font-woff'
}
}]
},
postcss: () => [autoprefixer],
plugins: [
new webpack.HotModuleReplacementPlugin(),
new CopyPlugin([{
from: 'assets/images/icons',
to: 'images/icons'
}]),
new webpack.optimize.OccurrenceOrderPlugin(),
new webpack.optimize.DedupePlugin(),
new ExtractTextPlugin('bundle.css')
]
.concat(
map(profileConfigs, (config, username) => new HtmlPlugin(Object.assign({
title: 'HWdTech Card',
filename: `${username}.html`,
favicon: './assets/images/favicon.ico',
template: './assets/templates/index.pug'
}, config.profile)))
)
};