feat(dev): dont override asset manifest in dev-server (#11648)

Override manifest.json only when `npm run dev`, not `npm run
dev-server`.  This allows developers to compare between the
current version of Superset with what they are working on
without switching back and forth between branches.

All they need to do is to first start the current version with
production build:

```
npm run build
superset run -p 8088
```

Then start the dev server in another window:

```
npm run dev-server
```
This commit is contained in:
Jesse Yang 2020-11-11 13:14:45 -08:00 committed by GitHub
parent a9f9c4bbd5
commit 4f21dea55f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 16 additions and 11 deletions

View File

@ -47,6 +47,7 @@ const {
nameChunks = false,
} = parsedArgs;
const isDevMode = mode !== 'production';
const isDevServer = process.argv[1].includes('webpack-dev-server');
const output = {
path: BUILD_DIR,
@ -94,17 +95,9 @@ const plugins = [
entrypoints: entryFiles,
};
},
// Also write to disk when using devServer
// instead of only keeping manifest.json in memory
// This is required to make devServer work with flask.
writeToFileEmit: isDevMode,
}),
// create fresh dist/ upon build
new CleanWebpackPlugin({
dry: false,
// required because the build directory is outside the frontend directory:
dangerouslyAllowCleanPatternsOutsideProject: true,
// Also write maniafest.json to disk when running `npm run dev`.
// This is required for Flask to work.
writeToFileEmit: isDevMode && !isDevServer,
}),
// expose mode variable to other modules
@ -126,9 +119,21 @@ const plugins = [
],
}),
];
if (!process.env.CI) {
plugins.push(new webpack.ProgressPlugin());
}
// clean up built assets if not from dev-server
if (!isDevServer) {
plugins.push(
new CleanWebpackPlugin({
// required because the build directory is outside the frontend directory:
dangerouslyAllowCleanPatternsOutsideProject: true,
}),
);
}
if (!isDevMode) {
// text loading (webpack 4+)
plugins.push(