forked from TurboWarp/desktop
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathwebpack.renderer.js
93 lines (91 loc) · 3.41 KB
/
webpack.renderer.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
const fs = require('fs');
const path = require('path');
const CopyWebpackPlugin = require('copy-webpack-plugin');
const merge = require('webpack-merge');
const libraryFilesFolder = path.resolve(__dirname, 'library-files');
if (!fs.existsSync(libraryFilesFolder)) {
fs.mkdirSync(libraryFilesFolder);
}
if (!fs.existsSync(path.join(libraryFilesFolder, '0a7b872042cecaf30cc154c0144f002b.svg'))) {
console.warn('You are missing library files, so the builtin sprite, costume, backdrop, and sound libraries will not work. Run `npm run fetch` to download them.');
}
if (!fs.existsSync(path.join(__dirname, 'static', 'packager.html'))) {
console.warn('You are missing the packager HTML, the builtin packager will not work. Run `npm run fetch` to download it.');
}
module.exports = defaultConfig => {
defaultConfig.module.rules = [];
return merge.smart(defaultConfig, {
devtool: '',
module: {
rules: [
{
test: /\.jsx?$/,
loader: 'babel-loader',
options: {
presets: ['@babel/preset-env', '@babel/preset-react'],
plugins: ['@babel/plugin-proposal-optional-chaining']
}
},
{
test: /\.(svg|png|wav|gif|jpg|mp3|ttf|otf)$/,
loader: 'file-loader',
options: {
outputPath: 'static/assets/',
esModule: false
}
},
{
test: /\.css$/,
use: [
{
loader: 'style-loader'
},
{
loader: 'css-loader',
options: {
importLoaders: 1,
modules: {
localIdentName: '[name]_[local]_[hash:base64:5]',
exportLocalsConvention: 'camelCase'
}
}
},
{
loader: 'postcss-loader',
options: {
postcssOptions: {
plugins: [
'postcss-import',
'postcss-simple-vars'
]
}
}
}
]
}
],
},
plugins: [
new CopyWebpackPlugin([
{
from: 'node_modules/scratch-blocks/media',
to: 'static/blocks-media'
},
{
from: libraryFilesFolder,
to: 'library-files'
}
])
],
resolve: {
alias: {
'scratch-gui$': path.resolve(__dirname, 'node_modules', 'scratch-gui', 'src', 'index.js'),
'scratch-render-fonts$': path.resolve(__dirname, 'node_modules', 'scratch-gui', 'src', 'lib', 'tw-scratch-render-fonts'),
}
},
output: {
libraryTarget: 'var'
},
target: 'web'
});
};