-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.conf.base.js
60 lines (59 loc) · 1.62 KB
/
webpack.conf.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
const CopyPlugin = require("copy-webpack-plugin");
const HtmlWebpackPlugin = require('html-webpack-plugin');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const path = require('path');
const project = require('./project.json');
const env = process.env.NODE_ENV || 'development';
module.exports = {
entry: [`${__dirname}/${project.source.scripts.index}`],
output: {
filename: project.dist.scripts.filename[env],
assetModuleFilename: project.dist.custom.filename[env],
publicPath: '/'
},
module: {
rules: [
{
test: /\.js$/,
exclude: /node_modules/,
use: 'babel-loader'
},
{
test: /\.css$/,
use: [ MiniCssExtractPlugin.loader, 'css-loader' ]
},
{
test: /\.styl$/,
use: [ MiniCssExtractPlugin.loader, 'css-loader', 'stylus-loader' ]
},
{
test: /\.(jpg|jpeg|png|svg)/,
type: 'asset/resource'
}
]
},
resolve: {
alias: {
'@environment$': `${__dirname}/${project.source.environments.root}/${env}.js`,
'@src': `${__dirname}/${project.source.root}`,
'@mixins': `${__dirname}/${project.source.styles.mixins}`
}
},
plugins: [
new HtmlWebpackPlugin({
template: project.source.index.file,
minify: { collapseWhitespace: true }
}),
new MiniCssExtractPlugin({
filename: project.dist.styles.filename[env]
}),
new CopyPlugin({
patterns: [
{
from: path.join(__dirname, project.source.images.files),
to: `${path.join(__dirname, project.dist.images.directory)}/[name][ext]`
}
]
})
]
}