-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.babel.js
63 lines (55 loc) · 1.46 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
import path from 'path';
import HtmlWebpackPlugin from 'html-webpack-plugin';
import ExtractTextPlugin from 'extract-text-webpack-plugin';
const pageList = [
'ui-kit',
'index',
'news',
'events',
'polls',
'messages',
'profile',
'contacts',
'terms',
];
const entries = pageList.reduce((acc, x) => (
{ [x]: ['babel-polyfill', `./pages/${x}.js`], ...acc }
), {});
const htmlPlugins = pageList.map(x => new HtmlWebpackPlugin({
template: `pages/${x}.pug`,
filename: `${x}.html`,
chunks: [x],
}));
export default {
entry: entries,
output: {
path: path.join(__dirname, 'build'),
filename: '[name].bundle.js',
},
module: {
loaders: [
{
test: /\.js$/,
loader: 'babel',
include: [path.resolve(__dirname, 'web_modules'), path.resolve(__dirname, 'pages')],
query: { presets: ['babel-preset-latest'] },
},
{ test: /\.pug$/, loader: 'pug' },
{ test: /\.json$/, loader: 'json' },
{ test: /\.(css|styl)/, loader: ExtractTextPlugin.extract('css!stylus') },
{ test: /\.(svg|png|ico|jpeg|ttf|eot|woff|woff2)(\?v=.+)?$/, loader: 'file?name=[path][name].[ext]' },
],
},
stylus: {
import: ['~shared/constants.styl'],
},
plugins: [
new ExtractTextPlugin('[name].css', { allChunks: true }),
].concat(htmlPlugins),
resolve: {
alias: {
'font-awesome.css': 'font-awesome/css/font-awesome.min.css',
'user-photos': 'blocks/user-profile/user-photos/',
},
},
};