0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-02-17 23:44:39 -05:00

Updated local start mode script

no issues

- adds new start-combined script which combines all chunks in `yarn start` for local portal development
- allows easier loading of local portal bundle in ghost via load-portal script, which needs to inject single script
- updates `yarn start:dev` to use updated script which uses the combined mode for better local development

refs
https://gist.github.com/simpixelated/90a3c16c3ed268fe24f5e5c9585ced2f
This commit is contained in:
Rishabh 2021-06-16 20:47:23 +05:30 committed by Rishabh Garg
parent 6e2952901a
commit 885fe178dd
4 changed files with 18 additions and 6 deletions

View file

@ -26,7 +26,8 @@
"react-scripts": "4.0.3"
},
"scripts": {
"start": "react-scripts start",
"start": "BROWSER=none react-scripts start",
"start:combined": "BROWSER=none node ./scripts/start-combined.js",
"start:dev": "node ./scripts/start-mode.js",
"dev": "node ./scripts/dev-mode.js",
"build": "npm run build:combined",

View file

@ -1,4 +1,4 @@
/** Script to load live Portal script chunks for local development */
/** Script to load Portal bundle for local development */
function loadScript(src) {
var script = document.createElement('script');
script.src = src;
@ -6,6 +6,3 @@ function loadScript(src) {
}
loadScript('http://localhost:3000/static/js/bundle.js');
loadScript('http://localhost:3000/static/js/1.chunk.js');
loadScript('http://localhost:3000/static/js/0.chunk.js');
loadScript('http://localhost:3000/static/js/main.chunk.js');

View file

@ -0,0 +1,14 @@
const rewire = require('rewire');
const defaults = rewire('react-scripts/scripts/start.js');
let configFactory = defaults.__get__('configFactory');
defaults.__set__('configFactory', (env) => {
const config = configFactory(env);
config.optimization.splitChunks = {
cacheGroups: {
default: false
}
};
config.optimization.runtimeChunk = false;
return config;
});

View file

@ -77,7 +77,7 @@ function doYarnStart() {
return;
}
const options = getBuildOptions();
yarnStartProcess = spawn('BROWSER=none yarn start', options);
yarnStartProcess = spawn('yarn start:combined', options);
['SIGINT', 'SIGTERM'].forEach(function (sig) {
yarnStartProcess.on(sig, function () {