rollup-plugin-sass icon indicating copy to clipboard operation
rollup-plugin-sass copied to clipboard

insertStyle function gets missed when npm pack or yarn pack made on final build files

Open SanthoshDhandapani opened this issue 5 months ago • 4 comments

Hi folks,

Thanks for all your great works on this plugin.

Screenshot 2024-09-04 at 7 03 55 PM

I understand that this function was created in reference to the following PR:

https://github.com/elycruz/rollup-plugin-sass/pull/139

However, we are facing an issue: whenever we publish our build module, the node_modules directory inside the build directory is completely ignored. As a result, node_modules/rollup-plugin-sass is not available, and our npm module throws an error because it cannot find import insertStyle from '../node_modules/rollup-plugin-sass/dist/insertStyle.js'; in the bundled scss.js files.

To simulate this issue, when we run npm pack or yarn pack, we get a tar file of the build directory. When we unpack these files, we do not see the node_modules directory inside the build directory.

Rollup Config:

output: [ { dir: "build/cjs", format: "cjs", exports: "named", preserveModules: true, // Indicates not create a single-file bundle preserveModulesRoot: "src", }, { dir: "build/esm", format: "esm", exports: "named", preserveModules: true, preserveModulesRoot: "src", }, ], plugins: [ sass({ output: true, insert: true, processor: (css) => postcss([autoprefixer]) .process(css, { from: undefined }) .then((result) => result.css), }) ]

Is there a way you can create the file outside the node module and refer it to the scss.js file or please suggest a possible fix after analyzing this issue.

SanthoshDhandapani avatar Sep 04 '24 14:09 SanthoshDhandapani