Skip to content

Commit

Permalink
CS fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Machy8 committed Jan 14, 2023
1 parent 7f61748 commit 2b596de
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
4 changes: 2 additions & 2 deletions packages/bundler/src/Bundler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -659,7 +659,7 @@ export class Bundler {
'bundler:beforeCssFileCreated', { content: generatedCss, bundleConfig }
);

let outputFileContent = hookData.content as string;
let outputFileContent = hookData.content;
const isDev = bundleBuildCache.compiler.dev;
const whiteSpace = isDev ? '\n' : '';

Expand All @@ -669,7 +669,7 @@ export class Bundler {
typeof exportLayerName === 'undefined' || !exportLayerName.includes(bundleConfig.cssLayer)
? ''
: `@layer ${this.cssLayersOrder.order};${whiteSpace.repeat(2)}`;
layerContent += `@layer ${bundleConfig.cssLayer} {${whiteSpace}${outputFileContent}${whiteSpace}}`;
layerContent += `@layer ${bundleConfig.cssLayer} {${whiteSpace + outputFileContent + whiteSpace}}`;
outputFileContent = layerContent;
}

Expand Down
10 changes: 6 additions & 4 deletions packages/bundler/tests/jest/css-layers.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,16 @@ if (!fs.existsSync(buildTmpDir)) {

fse.copySync(path.join(bundleTestDir, 'input'), buildTmpDir);

test('Single file', (): void => {
return;
new Bundler({
test('Single file', async (): void => {
const bundler = new Bundler({
dev: true,
cssLayersOrder: {
order: ['layout', 'page'].join(','),
exportLayer: ['layout'],
exportFile: path.join(buildTmpDir, 'stylify-css-layers.css')
}
}).bundle([
})
bundler.bundle([
{
outputFile: path.join(buildTmpDir, 'layout.css'),
files: [ path.join(buildTmpDir, 'layout.html') ],
Expand All @@ -38,6 +38,8 @@ test('Single file', (): void => {
},
]);

await bundler.waitOnBundlesProcessed();

const layoutCssOutput = testUtils.readFile(path.join(buildTmpDir, 'layout.css'));
const pageCssOutput = testUtils.readFile(path.join(buildTmpDir, 'page.css'));
const layersCssOutput = testUtils.readFile(path.join(buildTmpDir, 'stylify-css-layers.css'));
Expand Down
4 changes: 3 additions & 1 deletion packages/unplugin/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,9 @@ export const unplugin = createUnplugin((config: UnpluginConfigInterface|Unplugin
await bundlerRunner.waitOnBundlesProcessed();
};

const shouldMangleSelectors = () => pluginConfig?.compiler?.mangleSelectors

// eslint-disable-next-line @typescript-eslint/no-unsafe-return
const shouldMangleSelectors = (): boolean => pluginConfig?.compiler?.mangleSelectors
?? pluginConfig?.bundler?.compiler?.mangleSelectors
?? (!pluginConfig.dev && !pluginConfig.bundler.watchFiles);

Expand Down

0 comments on commit 2b596de

Please sign in to comment.