mirror of
https://github.com/enso-org/enso.git
synced 2025-01-03 23:22:15 +03:00
Fix .png
and .svg
loading errors (#7442)
* Fix resource building * Simplify plugin regex * Include `.svg` files in regex
This commit is contained in:
parent
ece18537e4
commit
7441a9a62c
@ -127,18 +127,31 @@ export function bundlerOptions(args: Arguments) {
|
|||||||
outbase: 'src',
|
outbase: 'src',
|
||||||
plugins: [
|
plugins: [
|
||||||
{
|
{
|
||||||
// This file MUST be in CommonJS format because it is loaded using `Function()`
|
name: 'override-loaders',
|
||||||
// in `ensogl/pack/js/src/runner/index.ts`.
|
|
||||||
// All other files are ESM because of `"type": "module"` in `package.json`.
|
|
||||||
name: 'pkg-js-is-cjs',
|
|
||||||
setup: build => {
|
setup: build => {
|
||||||
build.onLoad({ filter: /[/\\]pkg.js$/ }, async info => {
|
// This file MUST be in CommonJS format because it is loaded using `Function()`
|
||||||
|
// in `ensogl/pack/js/src/runner/index.ts`.
|
||||||
|
// All other files are ESM because of `"type": "module"` in `package.json`.
|
||||||
|
build.onLoad({ filter: /[/\\]pkg\.js$/ }, async info => {
|
||||||
const { path } = info
|
const { path } = info
|
||||||
return {
|
return {
|
||||||
contents: await fs.readFile(path),
|
contents: await fs.readFile(path),
|
||||||
loader: 'copy',
|
loader: 'copy',
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
// `.png` and `.svg` files not in the `assets` module should not use the `file`
|
||||||
|
// loader.
|
||||||
|
build.onLoad({ filter: /(?:\.png|\.svg)$/ }, async info => {
|
||||||
|
const { path } = info
|
||||||
|
if (!/[/\\]assets[/\\][^/\\]*(?:\.png|\.svg)$/.test(path)) {
|
||||||
|
return {
|
||||||
|
contents: await fs.readFile(path),
|
||||||
|
loader: 'copy',
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
})
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
esbuildPluginCopyDirectories(),
|
esbuildPluginCopyDirectories(),
|
||||||
|
Loading…
Reference in New Issue
Block a user