forked from scratchfoundation/scratch-vm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
124 lines (117 loc) · 3.11 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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
const path = require('path');
const CopyWebpackPlugin = require('copy-webpack-plugin');
const webpack = require('webpack');
const ScratchWebpackConfigBuilder = require('scratch-webpack-configuration');
const common = {
libraryName: 'scratch-vm',
rootPath: path.resolve(__dirname)
};
const nodeBuilder = new ScratchWebpackConfigBuilder(common)
.setTarget('node')
.addModuleRule({
test: /\.mp3$/,
type: 'asset'
});
const webBuilder = new ScratchWebpackConfigBuilder(common)
.setTarget('browserslist')
.merge({
resolve: {
fallback: {
Buffer: require.resolve('buffer/')
}
}
})
.addModuleRule({
test: /\.mp3$/,
type: 'asset'
})
.addModuleRule({
test: require.resolve('./src/index.js'),
loader: 'expose-loader',
options: {
exposes: 'VirtualMachine'
}
})
.addPlugin(new webpack.ProvidePlugin({
Buffer: ['buffer', 'Buffer']
}));
const playgroundBuilder = webBuilder.clone()
.merge({
devServer: {
contentBase: false,
host: '0.0.0.0',
port: process.env.PORT || 8073
},
performance: {
hints: false
},
entry: {
'benchmark': './src/playground/benchmark',
'video-sensing-extension-debug': './src/extensions/scratch3_video_sensing/debug'
},
output: {
path: path.resolve(__dirname, 'playground')
}
})
.addModuleRule({
test: require.resolve('stats.js/build/stats.min.js'),
loader: 'script-loader'
})
.addModuleRule({
test: require.resolve('./src/extensions/scratch3_video_sensing/debug.js'),
loader: 'expose-loader',
options: {
exposes: 'Scratch3VideoSensingDebug'
}
})
.addModuleRule({
test: require.resolve('scratch-blocks/dist/vertical.js'),
loader: 'expose-loader',
options: {
exposes: 'Blockly'
}
})
.addModuleRule({
test: require.resolve('scratch-audio/src/index.js'),
loader: 'expose-loader',
options: {
exposes: 'AudioEngine'
}
})
.addModuleRule({
test: require.resolve('scratch-storage/src/index.js'),
loader: 'expose-loader',
options: {
exposes: 'ScratchStorage'
}
})
.addModuleRule({
test: require.resolve('scratch-render/src/index.js'),
loader: 'expose-loader',
options: {
exposes: 'ScratchRender'
}
})
.addPlugin(new CopyWebpackPlugin([
{
from: 'node_modules/scratch-blocks/media',
to: 'media'
},
{
from: 'node_modules/scratch-storage/dist/web'
},
{
from: 'node_modules/scratch-render/dist/web'
},
{
from: 'node_modules/scratch-svg-renderer/dist/web'
},
{
from: 'src/playground'
}
]));
module.exports = [
nodeBuilder.get(),
webBuilder.get(),
playgroundBuilder.get()
];