-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.conf.base.js
58 lines (57 loc) · 1.53 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
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.images.filename[env]
},
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}`
}
},
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.favicon.files),
to: `${path.join(__dirname, project.dist.images.directory)}/[name][ext]`
}
],
})
]
}