-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwebpack.config.js
More file actions
77 lines (74 loc) · 1.97 KB
/
webpack.config.js
File metadata and controls
77 lines (74 loc) · 1.97 KB
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
const HtmlWebpackPlugin = require('html-webpack-plugin');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const path = require('path');
const webpack = require('webpack');
const env = process.env.NODE_ENV || 'development';
const isDev = env === 'development';
module.exports = {
mode: env,
entry: {
core: 'core-js/stable',
regenerator: 'regenerator-runtime/runtime',
bundle: path.join(__dirname, './src/index.js'),
},
output: {
path: path.join(__dirname, './docs'),
filename: '[name].js',
publicPath: isDev ? '/' : '/fifteen/',
},
resolve: {
alias: {
'react-dom': '@hot-loader/react-dom',
},
},
module: {
rules: [
{
test: /\.js$/,
include: path.join(__dirname, './src'),
use: { loader: 'babel-loader' },
},
{
test: /\.css$/,
include: path.join(__dirname, './node_modules'),
use: [{ loader: 'style-loader' }, { loader: 'css-loader' }],
},
{
test: /\.less$/,
include: path.join(__dirname, './src'),
use: [
isDev ? { loader: 'style-loader' } : { loader: MiniCssExtractPlugin.loader },
{
loader: 'css-loader',
options: {
importLoaders: 1,
modules: {
mode: 'local',
exportGlobals: true,
localIdentName: '[path][name]__[local]--[hash:base64:5]',
localIdentContext: path.join(__dirname, './src'),
},
},
},
{ loader: 'less-loader' },
],
},
],
},
plugins: [
new HtmlWebpackPlugin({
template: path.join(__dirname, './src/index.html'),
cache: true,
inject: 'body',
}),
new webpack.HotModuleReplacementPlugin(),
new MiniCssExtractPlugin({
filename: '[name].css',
}),
],
devServer: {
static: { directory: path.join(__dirname, './docs') },
hot: true,
historyApiFallback: true,
},
};