mirror of
https://github.com/teoxoy/factorio-blueprint-editor.git
synced 2024-11-24 08:22:16 +02:00
use pluginReplace for env variables
This commit is contained in:
parent
400d95f297
commit
54006ac798
@ -15,7 +15,7 @@ import { initActions, registerAction } from './actions'
|
||||
export class Editor {
|
||||
public async init(canvas: HTMLCanvasElement): Promise<void> {
|
||||
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),
|
||||
|
@ -39,7 +39,7 @@ function getBT(path: string): Promise<PIXI.BaseTexture> {
|
||||
}
|
||||
|
||||
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,
|
||||
|
@ -147,7 +147,7 @@ function getBlueprintOrBookFromSource(source: string): Promise<Blueprint | Book>
|
||||
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('/')
|
||||
|
@ -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') },
|
||||
|
Loading…
Reference in New Issue
Block a user