Trying to fix front end resources to be agnostic.

This commit is contained in:
Dessalines 2019-03-16 08:39:27 -07:00
parent b95b321c3d
commit e790b7af12
3 changed files with 3 additions and 17 deletions

View File

@ -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();
});

View File

@ -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);
});
}

1
server/ui/src/env.ts Normal file
View File

@ -0,0 +1 @@
export const endpoint = window.location.origin;