dev: add dev2 env

This commit is contained in:
KernelDeimos 2024-10-19 18:22:09 -04:00
parent 0fb4f73d76
commit b5535ae3ca
2 changed files with 8 additions and 2 deletions

View File

@ -64,6 +64,11 @@ window.gui = async function(options){
// await window.loadScript(`${options.asset_dir}/initgui.js`, {isModule: true});
}
if (window.gui_env === 'dev2') {
await window.loadScript('/puter.js/v2');
await window.loadCSS('/dist/bundle.min.css');
}
// PROD: load the minified bundles if we are in production mode
// note: the order of the bundles is important
// note: Build script will prepend `window.gui_env="prod"` to the top of the file

View File

@ -52,6 +52,7 @@ const __dirname = path.dirname(fileURLToPath(import.meta.url));
* });
*/
async function build(options){
const PUTER_ENV = process.env.PUTER_ENV || 'prod';
// -----------------------------------------------
// Delete ./dist/ directory if it exists and create a new one
// -----------------------------------------------
@ -132,7 +133,7 @@ async function build(options){
const webpack_opts = {
...(await BaseConfig({
...options,
env: 'prod',
env: PUTER_ENV,
})),
mode: 'production',
optimization: {
@ -158,7 +159,7 @@ async function build(options){
// Prepend `window.gui_env="prod";` to `./dist/gui.js`
fs.writeFileSync(
path.join(__dirname, 'dist', 'gui.js'),
`window.gui_env="prod"; \n\n` + fs.readFileSync(path.join(__dirname, 'src', 'index.js'))
`window.gui_env="${PUTER_ENV}"; \n\n` + fs.readFileSync(path.join(__dirname, 'src', 'index.js'))
);
const copy_these = [