-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.base.js
94 lines (91 loc) · 2.38 KB
/
webpack.config.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
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
92
93
94
'use strict';
const path = require('path');
const ESLintPlugin = require('eslint-webpack-plugin');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const ctxDir = path.resolve(__dirname);
const srcDir = path.resolve(ctxDir, 'src');
const outDir = path.resolve(ctxDir, 'dist');
const publicPath = '/';
module.exports = {
mode: 'development',
devtool: 'cheap-module-source-map',
context: ctxDir,
entry: {
main: ['normalize.css', srcDir],
react: [
'react', 'react-dom',
'react-router', 'react-router-dom'
]
},
output: {
path: outDir,
publicPath,
filename: '[name].[chunkhash].js'
},
resolve: {
alias: {
'src': srcDir,
'jsmediatags$': 'jsmediatags/dist/jsmediatags.min.js'
}
},
module: {
rules: [{
test: /\.css$/,
include: [/node_modules/],
use: [{
loader: MiniCssExtractPlugin.loader
}, {
loader: 'css-loader'
}]
}, {
test: /\.less$/,
include: [srcDir],
use: [{
loader: MiniCssExtractPlugin.loader
}, {
loader: 'css-loader',
options: {
sourceMap: true,
modules: {
mode: 'local',
localIdentName: '[local]-[hash:base64:5]'
},
importLoaders: 2
}
}, {
loader: 'postcss-loader',
options: {
sourceMap: true
}
}, {
loader: 'less-loader',
options: {
sourceMap: true
}
}]
}, {
test: /\.js$/,
include: [srcDir],
use: [{
loader: 'babel-loader'
}]
}]
},
optimization: {
splitChunks: {
chunks: 'all'
}
},
plugins: [
new ESLintPlugin(),
new HtmlWebpackPlugin({
template: 'src/index.html',
cache: false,
hash: true
}),
new MiniCssExtractPlugin({
filename: '[name].[chunkhash].css'
})
]
};