-
Notifications
You must be signed in to change notification settings - Fork 42
/
webpack.common.js
53 lines (52 loc) · 1.43 KB
/
webpack.common.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
const webpack = require('webpack');
const path = require('path');
const WrapperPlugin = require('wrapper-webpack-plugin');
module.exports = {
target: ['web', 'es2021'],
entry: {
'ui-completion-rules': './ui/src/completion-rules.tsx',
'ui-levels': './ui/src/levels.tsx',
},
output: {
filename: '[name]-lazy.js',
path: path.resolve(__dirname, './amd/src'),
libraryTarget: 'amd',
},
module: {
rules: [
{
test: /\.tsx?$/,
use: 'ts-loader',
exclude: /node_modules/,
},
],
},
resolve: {
extensions: ['.tsx', '.ts', '.js'],
},
optimization: {
splitChunks: {
cacheGroups: {
commons: {
test: /[\\/]node_modules[\\/]/,
name: 'ui-commons',
chunks: 'all'
}
}
}
},
plugins: [
// Wrap the ui-commons to make it an AMD module.
new WrapperPlugin({
test: /ui-commons-lazy\.js$/,
header: 'define(() => {\n',
footer: '\n});'
}),
// Without this, Moodle prevents grunt from compiling the files.
new WrapperPlugin({
test: /-lazy\.js$/,
header: '/* eslint-disable */\n/* Do not edit directly, refer to ui/ folder. */\n\n',
footer: ''
}),
],
};