tpa-style-webpack-plugin
Version:
A Webpack plugin that handles wix tpa styles, it separates static css file that injects dynamic style at runtime.
24 lines (23 loc) • 1.28 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.getRelatedStyleParamsFileName = exports.generateStandaloneCssConfigFilename = void 0;
function generateStandaloneCssConfigFilename(fileName) {
return appendFileName(fileName, 'cssConfig');
}
exports.generateStandaloneCssConfigFilename = generateStandaloneCssConfigFilename;
function getRelatedStyleParamsFileName(fileName) {
/**
* this is a file name convention with Yoshi Flow Editor
* related:
* https://github.com/wix-private/yoshi/blob/7fd08397f8fb744a6fcceb38defd5afb90e86ba8/packages/yoshi-flow-editor/src/wrappers/stylesParamsWrapping.ts#L18
* https://github.com/wix-private/yoshi/blob/7fd08397f8fb744a6fcceb38defd5afb90e86ba8/packages/yoshi-flow-editor/src/wrappers/stylesParamsWrapping.ts#L27
*/
return appendFileName(fileName, 'stylesParams');
}
exports.getRelatedStyleParamsFileName = getRelatedStyleParamsFileName;
function appendFileName(fileName, injectedString) {
const parts = fileName.split('.');
const hasPart = (part) => parts.some(x => part === x);
const index = [hasPart('js'), hasPart('min'), hasPart('bundle')].filter(x => x).length;
return [...parts.slice(0, -index), injectedString, ...parts.slice(-index)].join('.');
}