-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathwebpack.config.js
99 lines (89 loc) · 2.67 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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
import CopyPlugin from 'copy-webpack-plugin';
import path, { dirname } from 'path';
import { fileURLToPath } from 'url';
const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);
// Determine the environment (e.g., testing or development)
const isTesting = process.env.NODE_ENV === 'development';
export default {
entry: {
main: './src/index.js',
},
output: {
filename: 'mr.js',
path: path.resolve(__dirname, 'dist'),
publicPath: 'auto',
libraryTarget: 'window',
},
devServer: {
https: true,
static: {
directory: path.join(__dirname, 'dist'),
},
client: {
overlay: {
errors: true,
warnings: false,
runtimeErrors: true,
},
},
compress: true,
},
optimization: {
minimize: false,
},
experiments: {
asyncWebAssembly: true,
},
resolve: {
extensions: ['.mjs', '.js'],
alias: {
mrjs: path.resolve(__dirname, './src'), // <-- When you build or restart dev-server, you'll get an error if the path to your global.js file is incorrect.
mrjsUtils: path.resolve(__dirname, './src/utils'),
},
fallback: {
fs: false,
path: false,
},
fullySpecified: false, // disable required .js / .mjs extensions when importing
},
mode: process.env.NODE_ENV || 'development',
plugins: [
new CopyPlugin({
patterns: [
// make these items generate in dist as default for the runner: index.html, style.css, and assets folder
{ from: 'samples/index-assets', to: 'index-assets' },
{ from: 'samples/index.html', to: 'index.html' },
{ from: 'samples/index-style.css', to: 'index-style.css' },
{ from: 'samples/examples', to: 'examples' },
{ from: 'samples/examples-assets', to: 'examples-assets' },
],
}),
],
module: {
rules: [
{
test: /\.m?js/,
type: 'javascript/auto',
},
{
test: /\.m?js/,
resolve: {
fullySpecified: false,
},
},
{
test: /\.wasm$/,
type: 'webassembly/async', // or 'webassembly/sync'
},
{
test: /\.css$/,
use: ['style-loader', 'css-loader'],
},
{
test: /\.json$/,
use: 'json-loader',
},
],
},
};