diff --git a/packages/editor/src/Editor.ts b/packages/editor/src/Editor.ts index dc11c2b4..a9bf0543 100644 --- a/packages/editor/src/Editor.ts +++ b/packages/editor/src/Editor.ts @@ -15,7 +15,7 @@ import { initActions, registerAction } from './actions' export class Editor { public async init(canvas: HTMLCanvasElement): Promise { await Promise.all([ - fetch(`${G.STATIC_URL}data.json`) + fetch('__STATIC_URL__/data.json') .then(res => res.text()) .then(modules => loadData(modules)), BasisLoader.loadTranscoder(basisTranscoderJS, basisTranscoderWASM), diff --git a/packages/editor/src/common/globals.ts b/packages/editor/src/common/globals.ts index f0401750..82421289 100644 --- a/packages/editor/src/common/globals.ts +++ b/packages/editor/src/common/globals.ts @@ -39,7 +39,7 @@ function getBT(path: string): Promise { } function getTexture(path: string, x = 0, y = 0, w = 0, h = 0): PIXI.Texture { - const key = `${STATIC_URL}${path.replace('.png', '.basis')}` + const key = `__STATIC_URL__/${path.replace('.png', '.basis')}` const KK = `${key}-${x}-${y}-${w}-${h}` let t = textureCache.get(KK) if (t) return t @@ -60,10 +60,7 @@ function getTexture(path: string, x = 0, y = 0, w = 0, h = 0): PIXI.Texture { return t } -const STATIC_URL = 'data/' - export default { - STATIC_URL, debug, hr, BPC, diff --git a/packages/editor/src/core/bpString.ts b/packages/editor/src/core/bpString.ts index 5f08c05b..e8a745ac 100644 --- a/packages/editor/src/core/bpString.ts +++ b/packages/editor/src/core/bpString.ts @@ -147,7 +147,7 @@ function getBlueprintOrBookFromSource(source: string): Promise reject(e) } }).then((url: URL) => { - const corsProxy = 'https://api.allorigins.win/raw?url=' + const corsProxy = '__CORS_PROXY_URL__' console.log(`Loading data from: ${url}`) const pathParts = url.pathname.slice(1).split('/') diff --git a/packages/website/tools/fuse.ts b/packages/website/tools/fuse.ts index 0ea80cee..0f69c9f2 100644 --- a/packages/website/tools/fuse.ts +++ b/packages/website/tools/fuse.ts @@ -1,5 +1,5 @@ import { join } from 'path' -import { fusebox, sparky, pluginLink } from 'fuse-box' +import { fusebox, sparky, pluginLink, pluginReplace } from 'fuse-box' import { IDevServerProps } from 'fuse-box/devServer/devServerProps' import { Context as FuseBoxContext } from 'fuse-box/core/context' import { wrapContents } from 'fuse-box/plugins/pluginStrings' @@ -37,6 +37,14 @@ class Context { plugins: [ this.luaPlugin, pluginLink(/basis_transcoder\.(js|wasm)$/, { useDefault: true }), + pluginReplace({ + __CORS_PROXY_URL__: runServer + ? 'https://api.allorigins.win/raw?url=' + : '/corsproxy?url=', + __STATIC_URL__: runServer + ? '/data' + : 'https://static-fbe.teoxoy.com/file/factorio-blueprint-editor', + }), ], cache: { enabled: runServer, strategy: 'memory' }, hmr: { plugin: p('./hmr.ts') },