@lynx-js/rspeedy
Version:
A webpack/rspack-based frontend toolchain for Lynx
42 lines (41 loc) • 1.44 kB
JavaScript
import { DEFAULT_DIST_PATH_INTERMEDIATE } from "./1~dist-path.js";
const defaultFilenameOptions = Object.freeze({
css: '[name]/[name].css'
});
const defaultDistPathOptions = Object.freeze({
css: DEFAULT_DIST_PATH_INTERMEDIATE
});
function pluginOutput(options) {
return {
name: 'lynx:rsbuild:output',
setup (api) {
api.modifyRsbuildConfig((config, { mergeRsbuildConfig })=>{
const lowerToVar = {
tools: {
rspack: {
output: {
environment: {
const: false
}
}
}
}
};
if (!options) return mergeRsbuildConfig(lowerToVar, {
output: {
filename: {
css: defaultFilenameOptions.css
}
}
}, config);
return mergeRsbuildConfig(lowerToVar, config, {
output: {
distPath: Object.assign({}, defaultDistPathOptions, options.distPath),
filename: Object.assign({}, defaultFilenameOptions, options.filename)
}
});
});
}
};
}
export { pluginOutput };