Open amithm7 opened 3 years ago
Yeah, @snowpack/plugin-webpack
explicitly cleans the build folder:
The reasoning makes sense to me, but IMO it shouldn't be forced. For instance, if you run the plugin with manifest: true
it could reasonably just remove all of the files listed in manifest.json
from the previous build and not touch anything else.
I've found it easiest to have the Webpack plugin write to a separate folder entirely, i.e.:
['@snowpack/plugin-webpack', {
extendConfig: (config) => {
config.output.path = path.resolve(__dirname, 'dist')
}
}]
That way build
is always the plain Snowpack build and dist
has your final bundle. Keeps things tidier, IMO, and it leaves build/index.html
linked to the original files instead of updating it with the hashed ones so you can always check that things are being built the way you want before Webpack does its thing.
@jalovatt I like your approach, rather than having both tools (webpack and snowpack build
) build to the same output folder, however, the method you proposed above config.output.path = path.resolve(__dirname, 'dist')
does not contain the index.html
entry point? do you have a solution that just leverages @snowpack/plugin-webpack
?
@jalovatt I like your approach, rather than having both tools (webpack and
snowpack build
) build to the same output folder, however, the method you proposed aboveconfig.output.path = path.resolve(__dirname, 'dist')
does not contain theindex.html
entry point? do you have a solution that just leverages@snowpack/plugin-webpack
?
Sorry, I forgot that I was using a local branch when I suggested that. For anyone else reading this, there is a PR to have the plugin respect the user's config.output.path
: #3255
Bug Report Quick Checklist
Describe the bug
While using plugin:
'@snowpack/plugin-webpack'
and build optionclean
set tofalse
, files inout
directory still get cleared.To Reproduce
clean: false,
and use plugin'@snowpack/plugin-webpack'
.out
directory.snowpack build --watch
The file written before snowpack build gets removed. As I am using
--watch
flag, this behaviour doesn't reproduce in subsequent writes.Expected behavior
Build
out
directory files be preserved asclean: false
option is set.