-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathwebpack.config.mjs
More file actions
76 lines (71 loc) · 1.49 KB
/
webpack.config.mjs
File metadata and controls
76 lines (71 loc) · 1.49 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
import path from 'path'
import { fileURLToPath } from 'url'
import webpack from 'webpack'
const __dirname = path.dirname(fileURLToPath(import.meta.url))
const buildDir = path.resolve(__dirname)
const distDir = path.resolve(buildDir, 'bundle')
const mode = process.env.NODE_ENV || 'production'
export default {
mode,
entry: path.join(buildDir, 'src', 'webpack.ts'),
devtool: 'source-map',
output: {
path: distDir,
filename: 'index.js',
library: 'ReactMSAView',
libraryTarget: 'umd',
},
devServer: {
port: 9000,
open: 'umd_example/',
headers: {
'Access-Control-Allow-Origin': '*',
'Access-Control-Allow-Headers': '*',
},
},
plugins: [
new webpack.optimize.LimitChunkCountPlugin({
maxChunks: 1,
}),
new webpack.ProvidePlugin({
React: 'react',
}),
],
resolve: {
extensions: [
'.mjs',
'.web.js',
'.js',
'.ts',
'.tsx',
'.json',
'.web.jsx',
'.jsx',
],
},
module: {
rules: [
{
oneOf: [
{
test: /\.m?[tj]sx?$/,
exclude: /(node_modules|bower_components)/,
use: {
loader: 'babel-loader',
options: {
rootMode: 'upward',
presets: ['@babel/preset-react'],
},
},
},
{
test: /\.css$/,
use: {
loader: 'css-loader',
},
},
],
},
],
},
}