-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwebpack.config.js
More file actions
108 lines (105 loc) · 2.36 KB
/
Copy pathwebpack.config.js
File metadata and controls
108 lines (105 loc) · 2.36 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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
const path = require('path');
const webpack = require('webpack');
const loaders = [
{
test: /\.(js|jsx)$/,
exclude: /node_modules/,
use: [
{
loader: 'babel-loader',
options: {
// This is a feature of `babel-loader` for Webpack (not Babel itself).
// It enables caching results in ./node_modules/.cache/babel-loader/
// directory for faster rebuilds.
cacheDirectory: true,
presets: [
'@babel/preset-env',
'@babel/preset-react',
{
plugins: ['@babel/plugin-proposal-class-properties'],
},
],
},
},
],
},
{
//add less to loaders
// Rules for SCSS files. Loaders run in reverse order
test: /\.(scss)$/,
exclude: /node_modules/,
use: [
{
loader: 'style-loader',
},
{
loader: 'css-loader',
},
{
loader: 'sass-loader',
},
],
}
];
module.exports = {
mode: 'production',
entry: './src/index.js',
output: {
publicPath: './',
path: path.resolve(__dirname, './build'),
filename: 'index.js',
//chunkFilename: '[name][chunkhash].bundle.js',
library: 'devt',
libraryTarget: 'umd',
umdNamedDefine: true,
},
plugins: [
new webpack.optimize.LimitChunkCountPlugin({
maxChunks: 1,
}),
],
module: {
rules: loaders,
},
node: {
net: 'empty',
tls: 'empty',
dns: 'empty',
},
resolve: {
extensions: ['.js', '.jsx'],
alias: {
react: path.resolve(__dirname, './node_modules/react'),
},
},
externals: {
// Don't bundle react or react-dom
react: {
commonjs: 'react',
commonjs2: 'react',
amd: 'React',
root: 'React',
},
"react-dom": {
commonjs: "react-dom",
commonjs2: "react-dom",
amd: "ReactDOM",
root: "ReactDOM"
}
},
optimization: {
minimize: true,
namedModules: true,
// runtimeChunk: 'single',
// splitChunks: {
// cacheGroups: {
// vendors: {
// test: /[\\/]node_modules[\\/]/,
// name: 'vendors',
// enforce: true,
// chunks: 'all',
// },
// },
// },
}
};