You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is set in 2 places in the CLI generated config:
run.ts line 17:
contentBase: config.output.path,
and also in the webback.config
devServer: {
contentBase: outDir,
// serve index.html for all 404 (required for push-state)
historyApiFallback: true
},
This causes the dev server to also serve files from the 'dist' directory in addition to the dynamically generated files from the webpack build which are served from a temporary in-memory virtual filesystem. (au run launches the webpack dev server, no files are outputted to the 'dist' dir)
This can cause confusion if files are left over in the 'dist' dir from previous production builds (au build --env prod). Newcomers to webpack will probably not realise that this can happen and the behaviour seems counter intuitive as the 'dist' dir is intended as purely an output dir for production builds.
The 'dist' build dir should not really be available as an input dir for serving via the dev server. I have however seen some implementations in other projects/frameworks that rely on this behaviour as they either store static files in the 'dist' dir or use a separate script outside of webpack to copy static assets over to the 'dist' dir. In that case the behaviour would be required to be able to access those files via the dev server.
By using the CopyWebpackPlugin to copy static assets as in the CLI generated webpack config, the static assets are copied into the temporary in-memory filesystem used by the dev server so are available to be served. This removes the need for also serving files from the 'dist' dir. and creates a more consistent dev/prod setup.
If contentBase is not set, as per the webpack docs, the dev server defaults to serving files from the current working dir, which means you can do this to retrieve the contents of package.json http://localhost:8080/package.json or any other servable file type.
Setting contentBase to false disables the static file serving altogether which should be the case here.
Current behavior:
Left over files in the 'dist' dir can be served when using au run which uses the webpack dev server.
Files from the dev build are served in preference to the files in 'dist' , but this can still cause unexpected issues or surprises in some circumstances.
What is the expected behavior?
Left over files in the 'dist' dir are not be served as it is purely an output dir in the CLI generated project template.
What is the motivation / use case for changing the behavior?
Avoid issues.
The text was updated successfully, but these errors were encountered:
I'm submitting a bug report
I'm submitting a feature request
The webpack dev server setting: 'contentBase' sets the path from where static content should be served from.
https://webpack.js.org/configuration/dev-server/#devserver-contentbase
This is set in 2 places in the CLI generated config:
run.ts line 17:
and also in the webback.config
This causes the dev server to also serve files from the 'dist' directory in addition to the dynamically generated files from the webpack build which are served from a temporary in-memory virtual filesystem. (
au run
launches the webpack dev server, no files are outputted to the 'dist' dir)This can cause confusion if files are left over in the 'dist' dir from previous production builds (
au build --env prod
). Newcomers to webpack will probably not realise that this can happen and the behaviour seems counter intuitive as the 'dist' dir is intended as purely an output dir for production builds.The 'dist' build dir should not really be available as an input dir for serving via the dev server. I have however seen some implementations in other projects/frameworks that rely on this behaviour as they either store static files in the 'dist' dir or use a separate script outside of webpack to copy static assets over to the 'dist' dir. In that case the behaviour would be required to be able to access those files via the dev server.
By using the CopyWebpackPlugin to copy static assets as in the CLI generated webpack config, the static assets are copied into the temporary in-memory filesystem used by the dev server so are available to be served. This removes the need for also serving files from the 'dist' dir. and creates a more consistent dev/prod setup.
If contentBase is not set, as per the webpack docs, the dev server defaults to serving files from the current working dir, which means you can do this to retrieve the contents of package.json
http://localhost:8080/package.json or any other servable file type.
Setting contentBase to false disables the static file serving altogether which should be the case here.
Current behavior:
Left over files in the 'dist' dir can be served when using
au run
which uses the webpack dev server.Files from the dev build are served in preference to the files in 'dist' , but this can still cause unexpected issues or surprises in some circumstances.
Left over files in the 'dist' dir are not be served as it is purely an output dir in the CLI generated project template.
Avoid issues.
The text was updated successfully, but these errors were encountered: