Skip to content

Commit 50c392c

Browse files
committed
Add devServerOnly option
1 parent cb48009 commit 50c392c

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

config/webpack.config.js

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ module.exports = (env, argv) => {
3636
*/
3737
const isSingleRepoMode = env.workspace_mode?.toLowerCase() === 'single';
3838
const isFastMode = env.fast?.toLowerCase() === 'true';
39+
const devServerOnly = env.dev_server_only?.toLowerCase() === 'true';
3940

4041
if (isFastMode) {
4142
console.log('Fast mode enabled: disabled sourcemaps, type-checking, ...');
@@ -103,7 +104,16 @@ module.exports = (env, argv) => {
103104
* copyFiles?: string[];
104105
* }
105106
*/
106-
const { entries, registry, copyFiles } = appPkg.visyn;
107+
108+
let {
109+
// eslint-disable-next-line prefer-const
110+
entries, registry, copyFiles, historyApiFallback,
111+
} = appPkg.visyn;
112+
113+
if (devServerOnly) {
114+
// If we do yarn start dev_server_only=true, we only want to start the dev server and not build the app (i.e. for proxy support).
115+
entries = {};
116+
}
107117

108118
const copyAppFiles = copyFiles?.map((file) => ({
109119
from: path.join(defaultAppPath, file),
@@ -266,7 +276,7 @@ module.exports = (env, argv) => {
266276
host: 'localhost',
267277
open: true,
268278
// Needs to be enabled to make SPAs work: https://stackoverflow.com/questions/31945763/how-to-tell-webpack-dev-server-to-serve-index-html-for-any-route
269-
historyApiFallback: true,
279+
historyApiFallback: historyApiFallback == null ? true : historyApiFallback,
270280
proxy: {
271281
// Append on top to allow overriding /api/v1/ for example
272282
...workspaceProxy,
@@ -625,7 +635,7 @@ module.exports = (env, argv) => {
625635
].filter(Boolean),
626636
},
627637
plugins: [
628-
new CleanWebpackPlugin(),
638+
!devServerOnly && new CleanWebpackPlugin(),
629639
isEnvDevelopment
630640
&& new ReactRefreshWebpackPlugin({
631641
overlay: false,

0 commit comments

Comments
 (0)