-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.prod.js
93 lines (91 loc) · 2.94 KB
/
webpack.config.prod.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 HtmlWebpackPlugin = require('html-webpack-plugin');
const path = require('path');
const webpack = require('webpack');
const autoprefixer = require('autoprefixer');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const CleanWebpackPlugin = require('clean-webpack-plugin');
const CopyWebpackPlugin = require('copy-webpack-plugin');
module.exports = {
context: __dirname,
entry: {
other: [
'./assets/js/other.js',
'./scss/other.scss'
],
main: [
'./assets/js/index.js',
'./scss/main.scss'
],
vendor: [
'jquery'
]
},
output: {
filename: 'assets/js/[name].js',
path: path.resolve('dist/'),
},
mode: 'production',
module: {
rules: [
{
test: /\.pug$/,
use: [
{ loader: 'pug-loader' }
]
},
{
test: /\.(eot|ttf|woff|woff2)$/,
use: [
{
loader: 'file-loader',
options: {
name: '../fonts/lato/[name].[ext]',
emitFile: false
}
}
]
},
{
test: /\.(css|scss)$/,
loader: ExtractTextPlugin.extract({
fallback: 'style-loader',
use: [
{
loader: 'css-loader',
},
{
loader: 'postcss-loader',
options: {
plugins: () => [autoprefixer({ browsers: ['> 1%', 'IE >= 10'] })],
},
},
{
loader: 'sass-loader',
},
],
}),
},
{
test: /\.(png|jpg|svg)$/,
use: [{
loader: 'url-loader',
options: {
}
}]
}
]
},
plugins: [
new CleanWebpackPlugin(['./dist']),
new CopyWebpackPlugin([{ from: 'assets/images', to: 'assets/images' }]),
new CopyWebpackPlugin([{ from: 'assets/fonts', to: 'assets/fonts' }]),
new ExtractTextPlugin('assets/css/[name].css'),
new webpack.HotModuleReplacementPlugin(),
new HtmlWebpackPlugin({ filename: 'index.html', template: './index.pug', favicon: 'assets/images/favicon-icon.ico', chunks: ['main'] }),
new HtmlWebpackPlugin({ filename: 'other.html', template: './other.pug', favicon: 'assets/images/favicon-icon.ico', chunks: ['app'] } ),
new webpack.ProvidePlugin({
$: 'jquery',
jQuery: 'jquery'
})
]
};