scss-bundle icon indicating copy to clipboard operation
scss-bundle copied to clipboard

'BundleAll' method causes /*** IMPORTED FILE NOT FOUND ***/ to be outputted

Open owenjs opened this issue 4 years ago • 2 comments

I have a use case for the 'BundleAll' method, so I'm using the same technique as suggested in #67.

However, the bundled files have the comment below appear multiple times.

/*** IMPORTED FILE NOT FOUND ***/
/*** --- ***/

It looks like the @imports which are causing this comment are the ones included in all of the files being bundled. Although one bundled file manages to output the bundled content for the import and the others do not. For example, I'm importing _variables.scss in all the files.

To fix this I'm instead initialising the Bundler class each time I iterate over my filesToBundle array:

const filesToWrite = await Promise.all(filesToBundle.map(async fileToBundle => {
    // Initialise Bundler
    const bundler = new Bundler(undefined, projectDirectory);
    // Bundle the File
    return await bundler.bundle(fileToBundle);
}));

This way the files bundle as expected.

I thought I'll mention it as I'm not sure if this is intended, if so #67 is the wrong replacement for 'BundleAll' for my use case.

Package version: v3.1.2 Node version: v14.10.0 OS: Windows

owenjs avatar Nov 14 '20 13:11 owenjs

I ran into this using Builder.bundle. Stepping through the issue I found that the path resolver for includePaths doesn't work if you set up your project using scss barrels. If you have a foo/index.scss and try to @import 'foo' it will try to resolve foo.scss and not check if foo is a directory with an index.scss. You'll either need to add the full path to your imports (@import 'foo/index') or flatten your directory structure until this is resolved.

JSMike avatar Jul 16 '21 00:07 JSMike

I got this problem in a project where I replaced the old, deprecated (in dart-sass) @import '~package-name/index'; referencing a barrel file with only @imports, with a more modern @import 'package-name'; . I had to revert the changes, keeping both the tilde and the /index. Using 3.1.2.

PhiLhoSoft avatar Jan 13 '22 09:01 PhiLhoSoft