-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
88 lines (87 loc) · 2.48 KB
/
webpack.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
const path = require('path');
/* Плагины */
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
// const ExtractTextPlugin = require('extract-text-webpack-plugin');
// const CleanWebpackPlugin = require('clean-webpack-plugin');
// const BundleAnalyzerPlugin = require('webpack-bundle-analyzer')
// .BundleAnalyzerPlugin;
// console.log('process.env', process.env);
/* Конфиг */
module.exports = {
entry: `${__dirname}/front/index`,
watch: true,
mode: 'development',
output: {
filename: 'index.js',
// chunkFilename: '[name].js',
path: path.resolve(__dirname, 'public/js')
},
plugins: [
// new ExtractTextPlugin('css/[name].css', {allChunks: true}),
new MiniCssExtractPlugin({
// Опции аналогичные webpackConfig.output
// но свойство path не работает!
// Решение: переназначение filename и chunkFilename
// https://stackoverflow.com/questions/51055490/minicssextractplugin-public-path-not-working
filename: '../css/[name].css',
chunkFilename: '../css/[name].css',
})
],
module: {
rules: [
{
test: /\.(js|jsx)$/,
// include: /front/,
include: [
path.resolve(__dirname, 'front'),
],
// exclude: /node_modules/,
loader: 'babel-loader'
},
{
test: /\.styl$/,
include: path.resolve(__dirname, 'front'),
use: [
'style-loader',
'css-loader',
{
loader: 'stylus-loader?paths=node_modules/bootstrap-stylus/stylus/&resolve url',
options: {
include: path.resolve(__dirname, 'front')
}
},
],
},
]
},
devtool: 'inline-source-map',
resolve: {
modules: [
'node_modules',
path.resolve(__dirname, 'front'),
],
mainFiles: ['index'],
extensions: ['.jsx', '.js', '.json', '.styl', '.css']
},
// plugins: [
// new CleanWebpackPlugin([`${TYPE}/static/js`]),
// new BundleAnalyzerPlugin({
// analyzerMode: 'static'
// })
// ]
// optimization: {
// // Удаляет собранное при возникновении ошибки
// noEmitOnErrors: true,
// // Разбиение на чанки
// splitChunks: {
// cacheGroups: {
// vendors: false,
// default: {
// minChunks: 3,
// name: 'common',
// chunks: 'all'
// }
// }
// }
// },
};