forked from ratelChief/AndersenProject
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
70 lines (61 loc) · 1.66 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
const webpack = require('webpack');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const path = require('path');
const autoprefixer = require('autoprefixer');
const postCssLoader = {
loader: 'postcss-loader',
options: {
plugins: [
autoprefixer({
browsers: ['last 2 versions']
})
]
}
};
const cssLoader = {
loader: 'css-loader',
options: {
camelCase: true,
modules: true,
localIdentName: '[name]__[local]___[hash:base64:5]'
}
};
const NODE_ENV = process.env.NODE_ENV || 'development';
module.exports = {
entry: `./src/index.js`, //что собирать
output: {
path: path.join(__dirname, '/public'), // куда выводить
publicPath: '/',
filename: 'bundle.js' // имя файла
},
watch: NODE_ENV === 'development', //включаем вотчер, только если окружение - девелопмент
watchOptions: {
aggregateTimeout: 100
},
devServer: {
hot: true,
historyApiFallback: true,
contentBase: './public'
},
devtool: 'source-map', // соурс мэп работает только, если окружение - девелопмнт, если продакшн - то соурс мэп отсутствует
plugins: [
new webpack.DefinePlugin({
NODE_ENV: JSON.stringify(NODE_ENV)
}),
new HtmlWebpackPlugin({
template: './public/index.html'
})
],
module: {
rules: [{
test: /\.(js|jsx)$/,
include: [/src/],
exclude: [/node_modules/],
loader: 'babel-loader'
},
{
test: /\.(css|less)$/,
use: ['style-loader', cssLoader, postCssLoader, 'less-loader']
}
] }
};