I hope snowpack can support the config like resolve.modules in webpack.
So, when i config path './src', I can write
import A from './src/component/A';
instand of
import A from 'component/A';
And @FredKSchott , I'm glad to create a PR myself if make sure this feature should be support.
Look like resolvealias: https://webpack.js.org/configuration/resolve/#resolvealias.
But in snowpack, we have different way to do it.
Just define an mount scripts: "mount:@/": "mount @/ --to /_dist_", then all import from '@/' will be mapped.
Snowpack don't care about the deps in file content. It just send it to broswer that broswer to handle it.
It doesn't seem to acknowledge mount paths when running $ snowpack build though, using src/App.js or src/App.css will throw and error with the Webpack plugin. I can confirm using relative paths works.
[error] ./_dist_/App.js
Module not found: Error: Can't resolve '/_dist_/App.css' in '/Users/user/Sites/build-test/.build/_dist_'
resolve '/_dist_/App.css' in '/Users/user/Sites/build-test/.build/_dist_'
I can make this into a new issue if it's not relevant to this ticket.
@Jonesy , can U give me a reproduction repo ?
@Akimyou You bet, here you go https://github.com/Jonesy/snowpack-mount-build-error. I get the error with snowpack build and snowpack build --bundle. Without webpack it builds fine. I also tried adding the alias to webpack manually using extendConfig but nothing seems to take.
Hey all, we're planning some big config improvements for Snowpack v2.7, including an explicit alias config for exactly what you're describing. See PR #603 for implementation.
Most helpful comment
Hey all, we're planning some big config improvements for Snowpack v2.7, including an explicit
aliasconfig for exactly what you're describing. See PR #603 for implementation.