Skip to content
This repository has been archived by the owner on Oct 25, 2022. It is now read-only.

Commit

Permalink
fix: Don't include settings in release build
Browse files Browse the repository at this point in the history
  • Loading branch information
oliversalzburg committed Jul 17, 2021
1 parent 651ef94 commit 82fe4f2
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 8 deletions.
2 changes: 1 addition & 1 deletion packages/userscript/bundle/kitten-scientists.user.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions packages/userscript/source/fixtures/savegame.ts
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
// This file is replaced during build as needed.
export default null;
2 changes: 2 additions & 0 deletions packages/userscript/source/fixtures/settings.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// This file is replaced during build as needed.
export default null;
17 changes: 10 additions & 7 deletions packages/userscript/source/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import testConfig from "./fixtures/localstorage.json";
import savegame from "./fixtures/savegame";
import devSavegame from "./fixtures/savegame";
import devSettings from "./fixtures/settings";
import { Options } from "./options/Options";
import { SettingsStorage } from "./options/SettingsStorage";
import { cinfo } from "./tools/Log";
Expand All @@ -11,8 +11,8 @@ import { UserScript } from "./UserScript";
const kittenGame = await UserScript.waitForGame();

// For development convenience, load a lategame save to give us more test options.
if (!isNil(savegame)) {
await new SavegameLoader(kittenGame).load(savegame);
if (!isNil(devSavegame)) {
await new SavegameLoader(kittenGame).load(devSavegame);
}

const userScript = await UserScript.getDefaultInstance();
Expand All @@ -25,9 +25,12 @@ import { UserScript } from "./UserScript";
if (legacySettings === null) {
cinfo("No legacy settings found. Default settings will be used.");
}
const options = Options.parseLegacyOptions(testConfig);
//const options = Options.parseLegacyOptions(legacySettings);
userScript.injectOptions(options);

if (!isNil(devSettings)) {
const options = Options.parseLegacyOptions(devSettings);
userScript.injectOptions(options);
}

userScript.run();

/*
Expand Down
4 changes: 4 additions & 0 deletions packages/userscript/webpack.config.inject.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ module.exports = {
},
plugins: [
new webpack.NormalModuleReplacementPlugin(/.\/fixtures\/savegame/, "./fixtures/lategame"),
new webpack.NormalModuleReplacementPlugin(
/.\/fixtures\/settings/,
"./fixtures/localstorage.json"
),
],
resolve: {
extensions: [".ts", ".js"],
Expand Down

0 comments on commit 82fe4f2

Please sign in to comment.