forked from scratchfoundation/scratch-vm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
134 lines (127 loc) · 3.47 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
125
126
127
128
129
130
131
132
133
134
const path = require('path');
const CopyWebpackPlugin = require('copy-webpack-plugin');
const ScratchWebpackConfigBuilder = require('scratch-webpack-configuration');
const common = {
libraryName: 'scratch-vm',
rootPath: path.resolve(__dirname)
};
const nodeBuilder = new ScratchWebpackConfigBuilder(common)
.setTarget('node')
.merge({
entry: {
'extension-worker': path.join(__dirname, 'src/extension-support/extension-worker.js')
},
output: {
library: {
name: 'VirtualMachine'
}
}
});
const webBuilder = new ScratchWebpackConfigBuilder(common)
.setTarget('browserslist')
.merge({
entry: {
'extension-worker': path.join(__dirname, 'src/extension-support/extension-worker.js')
},
resolve: {
fallback: {
Buffer: require.resolve('buffer/')
}
},
output: {
library: {
name: 'VirtualMachine'
}
}
})
.addModuleRule({
test: require.resolve('./src/index.js'),
loader: 'expose-loader',
options: {
exposes: 'VirtualMachine'
}
});
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',
'extension-worker': path.join(__dirname, 'src/extension-support/extension-worker.js')
},
output: {
path: path.resolve(__dirname, 'playground'),
library: {
name: 'VirtualMachine'
}
}
})
.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'),
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()
];