This repository has been archived by the owner on Sep 26, 2019. It is now read-only.
/
webpack.config.js
93 lines (89 loc) · 2.2 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
83
84
85
86
87
88
89
90
91
92
93
const glob = require('glob')
const path = require('path')
const webpack = require('webpack')
const PurifyCSSPlugin = require('purifycss-webpack')
const HtmlWebpackPlugin = require('html-webpack-plugin')
const ExtractTextPlugin = require('extract-text-webpack-plugin')
const config = [
require('./src/config/facts.json'),
require('./src/config/comm.json'),
require('./src/config/links.json')
]
function htmlPluginConfig (lang) {
const filename = `${lang === 'en' ? '' : lang + '/'}index.html`
return {
lang: lang,
config: config,
filename: filename,
template: './src/index.hbs',
minify: {
removeComments: true,
collapseWhitespace: true,
removeAttributeQuotes: true
}
}
}
module.exports = {
entry: [
'./src/index.css',
'@material/card/dist/mdc.card.css',
'@material/theme/dist/mdc.theme.css',
'@material/layout-grid/dist/mdc.layout-grid.css'
],
output: {
path: path.resolve('build'),
filename: 'main.[hash:8].js'
},
module: {
loaders: [
{
test: /\.svg$/,
loader: 'svg-inline-loader'
},
{
test: /\.css$/,
use: ExtractTextPlugin.extract({
fallback: 'style-loader',
use: 'css-loader'
})
},
{
test: /\.hbs$/,
loader: 'handlebars-loader',
query: {
helperDirs: [
path.join(__dirname, 'src', 'helpers')
],
partialDirs: [
path.join(__dirname, 'src', 'partials')
]
}
}
]
},
devServer: {
open: true,
openPage: '',
compress: true,
stats: 'minimal',
contentBase: path.join(__dirname, 'build')
},
plugins: [
new PurifyCSSPlugin({
minimize: true,
moduleExtensions: ['.hbs'],
paths: glob.sync(path.join(__dirname, 'src/**/*.hbs'))
}),
new webpack.optimize.UglifyJsPlugin({
comments: false,
compress: {
warnings: false
}
}),
new ExtractTextPlugin('[name].[hash:8].css'),
new HtmlWebpackPlugin(htmlPluginConfig('en')),
new HtmlWebpackPlugin(htmlPluginConfig('ja')),
new HtmlWebpackPlugin(htmlPluginConfig('zh-Hans')),
new HtmlWebpackPlugin(htmlPluginConfig('zh-Hant'))
]
}