-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Expand file tree
/
Copy pathwebpack.config.js
More file actions
68 lines (62 loc) · 1.83 KB
/
webpack.config.js
File metadata and controls
68 lines (62 loc) · 1.83 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
const path = require('node:path')
/**
* @import {Configuration, RuleSetRule} from "webpack"
*/
/**
* Base config that applies to either development or production mode.
* @satisfies {Configuration}
*/
const config = {
entry: './src/index.ts',
experiments: {
outputModule: true,
},
output: {
library: { type: 'module' },
path: path.resolve(__dirname, 'dist'),
filename: '[name].mjs',
clean: true,
},
resolve: {
extensions: ['.ts', '.js'],
},
module: {
rules: /** @type {RuleSetRule[]} */ ([
{
test: /\.ts$/,
use: 'ts-loader',
exclude: /node_modules/,
},
]),
},
// Enable webpack-dev-server to get hot refresh of the app.
devServer: {
static: './build',
},
devtool: /** @type {Configuration["devtool"]} */ (false),
ignoreWarnings: /** @type {Configuration["ignoreWarnings"]} */ ([]),
}
/**
* @returns {Configuration}
*/
module.exports = (env, argv) => {
if (argv.mode === 'development') {
// Set the output path to the `build` directory
// so we don't clobber production builds.
config.output.path = path.resolve(__dirname, 'build')
// Generate source maps for our code for easier debugging.
// Not suitable for production builds. If you want source maps in
// production, choose a different one from https://webpack.js.org/configuration/devtool
config.devtool = 'eval-cheap-module-source-map'
// Include the source maps for Blockly for easier debugging Blockly code.
config.module.rules.push({
test: /(blockly\/.*\.js)$/,
use: [require.resolve('source-map-loader')],
enforce: 'pre',
})
// Ignore spurious warnings from source-map-loader
// It can't find source maps for some Closure modules and that is expected
config.ignoreWarnings = [/Failed to parse source map/]
}
return config
}