Conversation
* update package name and version * test with empty options * fix resove path error * support compile fake css but js file * clean up * Revert "update package name and version" This reverts commit fd545d6. * fix fmt
| let sourceFullPath = resolve.sync(args.path, { | ||
| basedir: args.resolveDir | ||
| }); |
There was a problem hiding this comment.
This can resolve all imported files correctly, not only local but from node_modules.
| plugins = [], | ||
| modules = true, | ||
| rootDir = process.cwd(), | ||
| sassOptions = {}, | ||
| lessOptions = {}, | ||
| stylusOptions = {}, | ||
| writeToFile = true |
There was a problem hiding this comment.
Add this back to pass the test.
| if ( | ||
| sourceExt !== ".css" && | ||
| sourceExt !== ".sass" && | ||
| sourceExt !== ".scss" && | ||
| sourceExt !== ".less" && | ||
| sourceExt !== ".styl" | ||
| ) { | ||
| return; | ||
| } |
There was a problem hiding this comment.
The file may be a .js file, if so, we can skip it.
There was a problem hiding this comment.
Why not using a regular expression? if (!/\.(scss|sass|css|less|styl)/.test(sourceExt)) {. Or even extract that check into a separate function to make it more readable
function isStyle(extension) {
return /\.(scss|sass|css|less|styl)/.test(extension);
}
...
if (!isStyle(sourceExt) {
| "types": "src/modules.d.ts", | ||
| "dependencies": { | ||
| "autoprefixer": "^10.2.5", | ||
| "bulma": "^0.9.3", |
There was a problem hiding this comment.
Don't get why you add this as production dependency to get only the css. You should pay more attention and use less css. For the test it would be totally sufficient to create a test css file which contains the problematic css code.
| "postcss-modules": "^4.0.0", | ||
| "resolve-file": "^0.3.0", | ||
| "resolve": "^1.20.0", | ||
| "sass": "^1.x", |
There was a problem hiding this comment.
actually sass, less, stylus etc should also be just peerDependencies and no hard dependencies.
|
I would recommend you to switch to the esbuild-style-plugin. It's maintained and working in this regards |
This PR is cherry-pick from: baurine#4
What did:
Use resolve npm package instead of resolve-file npm package to resolve the import path, this can fix the 2 below bugs:
The root reason I have reported to resolve-file repo in doowb/resolve-file#2 (comment)