jsqrt / bun-bundler

Bun-Bundler: Modern, Simple, and Ultra-Fast HTML Bundler. Bun | Pug/HTML | SCSS/CSS | JS | SVG Sprite | Image optimizations
MIT License
4 stars 0 forks source link

Sass does can't import stylesheet #4

Open karneaud opened 5 days ago

karneaud commented 5 days ago

I'm not sure if its your package or my project dependency package but when trying to import node_modules/sass-library I get the error

Can't find/ import stylesheet, file does not exist

Usually

@import ~bootstrap/css/file or @use bootstrap/css/file would work but I had to reference it @forward .../../node_modules/.... which lead to more internal referencing issues.

I had to

this.config.jsFiles = exec(js);
this.config.staticFolders = exec(staticFolders);
this.config.sassLoadPaths = exec(sassLoadPaths); // add a configurations to allow search in folders other than source

and also

    await this.compile({
                filePaths: this.config.sassFiles,
                type: 'CSS',
                newFileExt: '.css',
                dist: this.config.cssDist,
                renderFn: (filePath) => sass.compile(filePath, { style: 'compressed',  loadPaths: this.config.sassLoadPaths  })?.css,

and it worked!

Maybe it could recognize .sassrc files in the project thus we can loadPaths from there ??

jsqrt commented 2 days ago

@karneaud

Added new parameters, I hope they will work for you.

Also it might be useful if you need to pass custom environment variables to the pug template.

bundler.build({
    sassConfigOverrides: {
        filePaths: ['../node_modules/'],
    },
    pugConfigOverrides: {},
    jsConfigOverrides: {},

    ...other options
});
karneaud commented 2 days ago

@jsqrt Good looking out! the pug configs would be useful