-
Notifications
You must be signed in to change notification settings - Fork 8
/
webpack.config.base.js
80 lines (78 loc) · 2.48 KB
/
webpack.config.base.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
var path = require('path')
var HtmlWebpackPlugin = require('html-webpack-plugin')
var MiniCssExtractPlugin = require('mini-css-extract-plugin')
var FaviconsWebpackPlugin = require('favicons-webpack-plugin')
const styleUses = (process.env.NODE_ENV === 'production') ? [{
loader: MiniCssExtractPlugin.loader,
options: {
publicPath: '/'
}
}, 'css-loader'] : ['style-loader', {
loader: 'css-loader',
options: {
module: true
}
}
]
module.exports = {
entry: [
'./source/scripts/index'
],
output: {
filename: 'js/[name].app.[hash:4].min.js',
path: path.join(__dirname, 'dist')
},
resolve: {
extensions: ['.js', '.jsx']
},
plugins: [
new MiniCssExtractPlugin({
filename: 'css/style.[hash:4].css',
chunkFilename: '[id].css'
}),
new FaviconsWebpackPlugin({
logo: path.join(__dirname, 'source', 'images',
'logo.png'),
prefix: 'icons-[hash]/',
}),
new HtmlWebpackPlugin({
title: 'stapp',
ghPage: process.env.GH_PAGES || false,
filename: 'index.html',
inject: false,
template: '!!ejs-loader!source/index.ejs'
})
],
module: {
rules: [{
test: /\.js$/,
loaders: ['babel-loader'],
include: path.join(__dirname, 'source/scripts')
}, {
test: /\.jsx$/,
loaders: ['babel-loader'],
include: path.join(__dirname, 'source/scripts')
}, {
test: /\.css$/,
use: styleUses
}, {
test: /\.(png|jpg)$/,
loader: 'file-loader?name=images/[name].[hash:4].[ext]'
}, {
test: /\.woff(\?v=\d+\.\d+\.\d+)?$/,
loader: 'file-loader?name=fonts/[name].[hash:4].[ext]&mimetype=application/font-woff'
}, {
test: /\.woff2(\?v=\d+\.\d+\.\d+)?$/,
loader: 'file-loader?name=fonts/[name].[hash:4].[ext]&mimetype=application/font-woff'
}, {
test: /\.ttf(\?v=\d+\.\d+\.\d+)?$/,
loader: 'file-loader?name=fonts/[name].[hash:4].[ext]&mimetype=application/octet-stream'
}, {
test: /\.eot(\?v=\d+\.\d+\.\d+)?$/,
loader: 'file-loader?name=fonts/[name].[hash:4].[ext]'
}, {
test: /\.svg(\?v=\d+\.\d+\.\d+)?$/,
loader: 'file-loader?name=images/[name].[hash:4].[ext]&mimetype=image/svg+xml'
}]
}
}