-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprod.config.js
91 lines (89 loc) · 2.55 KB
/
prod.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
/* eslint-disable no-undef */
const path = require('path');
const TerserJSPlugin = require('terser-webpack-plugin');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const OptimizeCSSAssetsPlugin = require('optimize-css-assets-webpack-plugin');
module.exports = function init() {
let config = {};
config.entry = {
app: ['./src/index.ts', './src/main.scss'],
vendor: ['./src/vendor.js', './src/vendor.scss']
};
config.output = {
path: path.resolve(__dirname, './dist'),
filename: '[name].bundle.js',
};
config.resolve = {
extensions: ['.ts', '.js', '.css', '.scss', '.html', '.json']
};
config.optimization = {
minimizer: [
new TerserJSPlugin({}),
new OptimizeCSSAssetsPlugin({})
],
};
config.plugins = [
new MiniCssExtractPlugin({
filename: '[name].bundle.css',
chunkFilename: '[id].css'
}),
new MiniCssExtractPlugin({
filename: '[name].bundle.scss',
chunkFilename: '[id].scss'
})
];
config.watch = true;
config.module = {
rules: [{
test: /\.js$/,
loader: 'babel-loader',
exclude: path.resolve(__dirname, 'node_modules'),
options: {
presets: ['@babel/preset-env']
}
},
{
test: /\.tsx?$/,
use: 'ts-loader',
exclude: path.resolve(__dirname, 'node_modules')
},
{
test: /\.scss$/,
use: [
MiniCssExtractPlugin.loader, {
loader: 'css-loader',
options: {
sourceMap: true,
importLoaders: 1
}
},
{
loader: 'postcss-loader',
options: {
config: {
path: './postcss.config.js'
}
}
},
{
loader: 'sass-loader',
options: {
sourceMap: true
}
},
],
},
{
test: /\.(png|jpg)$/,
loader: 'url-loader'
}
]
};
return config;
};
// Helper functions
// eslint-disable-next-line no-unused-vars
function root(args) {
args = Array.prototype.slice.call(arguments, 0);
return path.join.apply(path, [__dirname].concat(args));
}