-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
84 lines (83 loc) · 2.05 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
const path = require('path')
const { CleanWebpackPlugin } = require('clean-webpack-plugin')
const HtmlWebpackPlugin = require('html-webpack-plugin')
const LessPluginAutoPrefix = require('less-plugin-autoprefix')
module.exports = {
mode: 'development',
entry: {
app: path.resolve(__dirname, './src/react/index.jsx'),
},
output: {
filename: '[name].[chunkhash:8].js',
chunkFilename: '[name]_[chunkhash:8].bundle.js',
path: path.resolve(__dirname, './dist'),
publicPath: '/',
},
devtool: 'inline-source-map',
devServer: {
historyApiFallback: true,
port: 3000,
},
resolve: {
alias: {
'@': path.resolve(__dirname, './src/react'),
},
extensions: ['.js', '.jsx', '.json', '.ts', '.tsx'],
},
module: {
rules: [
{
test: /\.jsx?$/,
loader: 'babel-loader',
exclude: /node_modules/,
},
{
test: /\.less$/,
use: [
'style-loader',
{
loader: 'css-loader',
options: {
importLoaders: 2,
modules: {
localIdentName: '[local]--[hash:base64:8]',
},
},
},
{
loader: 'less-loader',
options: {
lessOptions: {
plugins: [
new LessPluginAutoPrefix({
enable: true,
options: {
browsers: ['last 3 versions'],
},
}),
],
},
sourceMap: false,
},
},
],
},
{
test: /\.(png|jpe?g|gif|svg)(\?.*)?$/,
loader: 'url-loader',
options: {
name: '[name].[hash:8].[ext]',
},
},
],
},
plugins: [
new HtmlWebpackPlugin({
filename: 'index.html',
template: path.resolve(__dirname, './src/react/public/index.html'),
favicon: path.resolve(__dirname, './src/react/public/favicon.ico'),
inject: true,
}),
new CleanWebpackPlugin(),
],
}