-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathwebpack.conf.base.js
48 lines (47 loc) · 1.34 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
const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const CopyWebpackPlugin = require('copy-webpack-plugin');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const project = require('./project.json');
const env = process.env.NODE_ENV || 'development';
module.exports = {
entry: [`${__dirname}/${project.scripts.source.index}`],
module: {
rules: [
{
test: /\.css$/,
use: [ MiniCssExtractPlugin.loader, 'css-loader' ]
},
{
test: /\.styl$/,
use: [ MiniCssExtractPlugin.loader, 'css-loader', 'stylus-loader' ]
},
{
test: /\.js$/,
exclude: /node_modules/,
use: 'babel-loader'
}
]
},
resolve: {
alias: {
'@data': `${__dirname}/${project.data.source.root}`,
'@environment$': `${__dirname}/${project.environments.source.root}/${env}.js`,
'@scripts': `${__dirname}/${project.scripts.source.root}`,
'@styles': `${__dirname}/${project.styles.source.root}`,
'@dist': `${__dirname}/${project.scripts.dist.root}`
}
},
plugins: [
new HtmlWebpackPlugin({
template: project.index.source.file,
minify: {
collapseWhitespace: true
}
}),
new CopyWebpackPlugin([{
from: project.images.source.files,
to: project.images.dist.root
}])
]
}