diff --git a/server/ui/fuse.js b/server/ui/fuse.js index 28c9b0e..ff1e6d1 100644 --- a/server/ui/fuse.js +++ b/server/ui/fuse.js @@ -11,7 +11,6 @@ const transformInferno = require('ts-transform-inferno').default; const transformClasscat = require('ts-transform-classcat').default; let fuse, app; let isProduction = false; -var setEnv = require('./set_env.js').setEnv; Sparky.task('config', _ => { fuse = new FuseBox({ @@ -44,16 +43,13 @@ Sparky.task('config', _ => { }); Sparky.task('clean', _ => Sparky.src('dist/').clean('dist/')); Sparky.task('env', _ => (isProduction = true)); -Sparky.task('set_env', _ => { - setEnv(); -}); Sparky.task('copy-assets', () => Sparky.src('assets/*.ico').dest('dist/')); -Sparky.task('dev', ['clean', 'set_env', 'config', 'copy-assets'], _ => { +Sparky.task('dev', ['clean', 'config', 'copy-assets'], _ => { fuse.dev(); app.hmr().watch(); return fuse.run(); }); -Sparky.task('prod', ['clean', 'set_env', 'env', 'config', 'copy-assets'], _ => { +Sparky.task('prod', ['clean', 'env', 'config', 'copy-assets'], _ => { // fuse.dev({ reload: true }); // remove after demo return fuse.run(); }); diff --git a/server/ui/set_env.js b/server/ui/set_env.js deleted file mode 100644 index a6fce7b..0000000 --- a/server/ui/set_env.js +++ /dev/null @@ -1,11 +0,0 @@ -require('dotenv').config(); -const fs = require('fs'); - -exports.setEnv = function() { - let endpoint = (process.env.TORRENTS_CSV_ENDPOINT) ? process.env.TORRENTS_CSV_ENDPOINT : "http://0.0.0.0:8080"; - let env_line = `export const endpoint = '${endpoint}';`; - fs.writeFile("src/env.ts", env_line, function (err) { - console.log("Wrote src/env.ts:"); - console.log("\t" + env_line); - }); -} diff --git a/server/ui/src/env.ts b/server/ui/src/env.ts new file mode 100644 index 0000000..55265cf --- /dev/null +++ b/server/ui/src/env.ts @@ -0,0 +1 @@ +export const endpoint = window.location.origin;