This repository has been archived by the owner on Jun 24, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathwebpack.config.js
106 lines (101 loc) · 3.15 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
94
95
96
97
98
99
100
101
102
103
104
105
106
var webpack = require('webpack');
var path = require('path');
var HtmlWebpackPlugin = require('html-webpack-plugin');
var MiniCssExtractPlugin = require('mini-css-extract-plugin');
const HtmlWebpackInlineSVGPlugin = require('html-webpack-inline-svg-plugin');
const dirSrc = path.join(__dirname, 'src');
const dirNode = 'node_modules';
var config = function (env, argv) {
const IS_DEV = (argv.mode === 'development');
return {
devServer: {
hot: true,
inline: true,
disableHostCheck: true
},
context: dirSrc,
devtool: 'eval',
output: {
pathinfo: true,
publicPath: '/',
filename: '[name].js'
},
stats: {
assets: false,
colors: true,
version: false,
hash: true,
timings: true,
chunks: false,
chunkModules: false
},
entry: {
index: path.join(dirSrc, 'index.pug'),
bundle: path.join(dirSrc, 'index.js'),
styles: path.join(dirSrc, 'styles.js'),
},
output: {
path: path.resolve(__dirname, 'dist'),
filename: 'js/[name].js'
},
module: {
rules: [{
test: /\.pug$/,
use: ['pug-loader']
},
{
test: /\.scss$/,
use: [{
loader: IS_DEV ? 'style-loader' : MiniCssExtractPlugin.loader,
}, {
loader: "css-loader",
options: {
sourceMap: true
}
}, {
loader: "sass-loader",
options: {
sourceMap: true
}
}]
},
{
test: /\.(gif|svg|png|pdf|pptx)$/,
loader: 'file-loader',
options: {
name: '[path][name].[ext]'
}
}, {
test: /\.(jpe?g)$/i,
loader: 'advanced-image-loader',
options: {
width: 1280,
srcset: [320, 640, 960, 1280, 1920],
quality: 80,
placeholder: 32
}
},
{
test: /\.js$/,
exclude: /(node_modules|bower_components)/,
use: {
loader: 'babel-loader',
}
}
]
},
plugins: [
new webpack.HotModuleReplacementPlugin(),
new HtmlWebpackPlugin({
title: 'index.html',
template: path.join(dirSrc, 'index.pug'),
}),
new HtmlWebpackInlineSVGPlugin(),
new MiniCssExtractPlugin({
filename: "[name].css",
chunkFilename: "[id].css"
}),
],
}
};
module.exports = config;