Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: support reference a scss files which installed to node_modules (#291) #302

Merged
merged 7 commits into from
May 29, 2020
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions playground/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,7 @@ import { createApp } from 'vue'
import App from './App.vue'
import './testHmrManual'

// test for sass @import
// import './styles/style.scss'

createApp(App).mount('#app')
5 changes: 3 additions & 2 deletions playground/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@
"serve": "serve dist"
},
"dependencies": {
"bootstrap": "^4.5.0",
daychongyang marked this conversation as resolved.
Show resolved Hide resolved
"conditional-exports": "link:./conditional-exports",
"lodash-es": "link:../node_modules/lodash-es",
"moment": "link:../node_modules/moment",
"rewrite-optimized-test-package": "link:./rewrite-optimized/test-package",
"resolve-browser-field-test-package": "link:./resolve-browser-field",
"conditional-exports": "link:./conditional-exports"
"rewrite-optimized-test-package": "link:./rewrite-optimized/test-package"
}
}
1 change: 1 addition & 0 deletions playground/styles/style.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
@import 'bootstrap/scss/bootstrap';
5 changes: 5 additions & 0 deletions playground/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
# yarn lockfile v1


bootstrap@^4.5.0:
version "4.5.0"
resolved "https://registry.yarnpkg.com/bootstrap/-/bootstrap-4.5.0.tgz#97d9dbcb5a8972f8722c9962483543b907d9b9ec"
integrity sha512-Z93QoXvodoVslA+PWNdk23Hze4RBYIkpb5h8I2HY2Tu2h7A0LpAgLcyrhrSUyo2/Oxm2l1fRZPs1e5hnxnliXA==

"conditional-exports@link:./conditional-exports":
version "0.0.0"
uid ""
Expand Down
7 changes: 2 additions & 5 deletions src/node/server/serverPluginModuleRewrite.ts
Original file line number Diff line number Diff line change
Expand Up @@ -254,11 +254,8 @@ export const resolveImport = (
// 3. resolve extensions.
const ext = resolver.resolveExt(pathname)
if (ext) {
pathname += ext
if (ext[0] === '/') {
// in aliased cases the inferred ext can contain multiple slashes
pathname = pathname.replace(/\/\/+/g, '/')
}
// in aliased cases the inferred ext can contain multiple slashes
pathname = path.posix.normalize(pathname + ext)
}

// 4. mark non-src imports
Expand Down
5 changes: 4 additions & 1 deletion src/node/utils/cssUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,10 @@ export async function compileCss(
postcssOptions: postcssConfig.options,
postcssPlugins: postcssConfig.plugins
}
: {})
: {}),
preprocessOptions: {
includePaths: ['node_modules']
}
})
}

Expand Down