Moving set_env to fusebox task. Fixes #30.
This commit is contained in:
parent
5249a21479
commit
6dcc7d5d07
|
@ -11,6 +11,7 @@ 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({
|
||||
|
@ -43,13 +44,16 @@ 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', 'config', 'copy-assets'], _ => {
|
||||
Sparky.task('dev', ['clean', 'set_env', 'config', 'copy-assets'], _ => {
|
||||
fuse.dev();
|
||||
app.hmr().watch();
|
||||
return fuse.run();
|
||||
});
|
||||
Sparky.task('prod', ['clean', 'env', 'config', 'copy-assets'], _ => {
|
||||
Sparky.task('prod', ['clean', 'set_env', 'env', 'config', 'copy-assets'], _ => {
|
||||
// fuse.dev({ reload: true }); // remove after demo
|
||||
return fuse.run();
|
||||
});
|
||||
|
|
|
@ -4,8 +4,6 @@
|
|||
"description": "A simple UI for Torrents.csv",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"prestart": "node set_env.js",
|
||||
"prebuild": "node set_env.js",
|
||||
"start": "node fuse dev",
|
||||
"build": "node fuse prod"
|
||||
},
|
||||
|
|
|
@ -1,17 +1,17 @@
|
|||
require('dotenv').config();
|
||||
const fs = require('fs');
|
||||
|
||||
|
||||
if (process.env.TORRENTS_CSV_ENDPOINT) {
|
||||
let env_line = `export const endpoint = '${process.env.TORRENTS_CSV_ENDPOINT}';`;
|
||||
fs.writeFile("src/env.ts", env_line, function (err) {
|
||||
if (err) {
|
||||
return console.log(err);
|
||||
}
|
||||
console.log("Found $TORRENTS_CSV_ENDPOINT, wrote src/env.ts");
|
||||
console.log("\t" + env_line);
|
||||
});
|
||||
} else {
|
||||
console.log("No $TORRENTS_CSV_ENDPOINT environment variable set, using http://0.0.0.0:8080");
|
||||
exports.setEnv = function() {
|
||||
if (process.env.TORRENTS_CSV_ENDPOINT) {
|
||||
let env_line = `export const endpoint = '${process.env.TORRENTS_CSV_ENDPOINT}';`;
|
||||
fs.writeFile("src/env.ts", env_line, function (err) {
|
||||
if (err) {
|
||||
return console.log(err);
|
||||
}
|
||||
console.log("Found $TORRENTS_CSV_ENDPOINT, wrote src/env.ts");
|
||||
console.log("\t" + env_line);
|
||||
});
|
||||
} else {
|
||||
console.log("No $TORRENTS_CSV_ENDPOINT environment variable set, using http://0.0.0.0:8080");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue