-
Notifications
You must be signed in to change notification settings - Fork 2
/
webpack.common.js
57 lines (49 loc) · 956 Bytes
/
webpack.common.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
const path = require('path')
const HtmlWebpackPlugin = require('html-webpack-plugin')
const PATH = {
mainJS: 'src/index.js',
template: 'src/index.html',
output: 'dist',
}
for (let key in PATH) {
PATH[key] = path.resolve(__dirname, PATH[key])
}
const CONFIG = {
entry: {
index: PATH.mainJS,
},
output: {
path: PATH.output,
filename: '[name].js',
assetModuleFilename: '[name]-[id][ext]',
sourcePrefix: '',
},
}
const cssLoaders = ['style-loader', 'css-loader']
CONFIG.module = {
rules: [
{
test: /\.css$/i,
use: cssLoaders,
},
{
test: /\.(scss|sass)$/i,
use: [...cssLoaders, 'sass-loader'],
},
{
test: /\.html$/i,
loader: 'html-loader',
},
{
test: /\.svg$/i,
use: 'raw-loader',
},
],
}
CONFIG.plugins = [
new HtmlWebpackPlugin({
filename: 'index.html',
template: PATH.template,
}),
]
module.exports = { CONFIG, PATH }