You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have the need to create a json file on the generateBundle callback which list all JS entries and their corresponding JS and CSS files.
It's used by my backend in order to create the corresponding script and link tags.
Here is how looks like my generateBundle hook for now:
async generateBundle(options, bundle, isWrite) {
if (!isWrite) {
return;
}
// Read manifest.json just wrote by rollup-plugin-output-manifest
const entrypoints = {
'entrypoints': {}
};
const manifest = {};
for (const [file, chunk] of Object.entries(bundle)) {
if (chunk.isEntry) {
const publicPath = config.publicPath + chunk.fileName;
// Add it into manifest
manifest[config.basePath + chunk.name + '.js'] = publicPath;
// Add it as a standalong entrypoints
entrypoints['entrypoints'][chunk.name] = {
'js': [publicPath]
};
// Add it with all it's import in entrypoints, used for mobile
const imports = [
publicPath
];
chunk.imports.forEach(imp => {
imports.push(config.publicPath + imp);
});
entrypoints['entrypoints'][chunk.name + '_all'] = {
'js': imports
};
}
}
this.emitFile({
type: 'asset',
fileName: 'entrypoints.json',
source: JSON.stringify(entrypoints, false, 2)
});
}
As you can see Im' relying on the imports array for JS file.
I tested many things using regular hooks, or editing the plugin to add more info.
I even tested to emit a new JSON file from the plugin that will contain info about what I need to and parse it in generatedBundle, but I cannot find a proper way to do that.
I'm struggling to find out a way to do everything I need.
I could take time to make a MR if somebody indicates me the proper ay to do what I need: A way to know in generateBundle the JS file that included a CSS file
The text was updated successfully, but these errors were encountered:
I'm using the
extract
mode in order to create separated CSS file.Let's say my rollup config list 2 files as inputs:
test1.js imports test1.css
test2.js imports test2.css
I have the need to create a json file on the
generateBundle
callback which list all JS entries and their corresponding JS and CSS files.It's used by my backend in order to create the corresponding script and link tags.
The JSON file needed should looks like:
Here is how looks like my
generateBundle
hook for now:As you can see Im' relying on the
imports
array for JS file.I tested many things using regular hooks, or editing the plugin to add more info.
I even tested to emit a new JSON file from the plugin that will contain info about what I need to and parse it in generatedBundle, but I cannot find a proper way to do that.
I'm struggling to find out a way to do everything I need.
I could take time to make a MR if somebody indicates me the proper ay to do what I need:
A way to know in
generateBundle
the JS file that included a CSS fileThe text was updated successfully, but these errors were encountered: