Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
71 changes: 71 additions & 0 deletions packages/wxt/e2e/tests/output-structure.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,77 @@ describe('Output Directory Structure', () => {
expect(await project.fileExists('.output/chrome-mv3/unlisted.js'));
});

it('should support CSS entrypoints', async () => {
const project = new TestProject();

project.addFile(
'entrypoints/plain-one.css',
`body {
font: 100% Helvetica, sans-serif;
color: #333;
}`,
);

project.addFile(
'entrypoints/plain-two.content.css',
`body {
font: 100% Helvetica, sans-serif;
color: #333;
}`,
);

project.addFile(
'entrypoints/sass-one.scss',
`$font-stack: Helvetica, sans-serif;
$primary-color: #333;

body {
font: 100% $font-stack;
color: $primary-color;
}`,
);

project.addFile(
'entrypoints/sass-two.content.scss',
`$font-stack: Helvetica, sans-serif;
$primary-color: #333;

body {
font: 100% $font-stack;
color: $primary-color;
}`,
);

await project.build();

expect(await project.serializeOutput(['.output/chrome-mv3/manifest.json']))
.toMatchInlineSnapshot(`
".output/chrome-mv3/assets/plain-one.css
----------------------------------------
body{font:100% Helvetica,sans-serif;color:#333}

================================================================================
.output/chrome-mv3/assets/sass-one.css
----------------------------------------
body{font:100% Helvetica,sans-serif;color:#333}

================================================================================
.output/chrome-mv3/content-scripts/plain-two.css
----------------------------------------
body{font:100% Helvetica,sans-serif;color:#333}

================================================================================
.output/chrome-mv3/content-scripts/sass-two.css
----------------------------------------
body{font:100% Helvetica,sans-serif;color:#333}

================================================================================
.output/chrome-mv3/manifest.json
----------------------------------------
<contents-ignored>"
`);
});

it("should output to a custom directory when overriding 'outDir'", async () => {
const project = new TestProject();
project.addFile('entrypoints/unlisted.html', '<html></html>');
Expand Down
5 changes: 4 additions & 1 deletion packages/wxt/src/core/builders/vite/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,10 @@ export async function createViteBuilder(
async build(group) {
let entryConfig;
if (Array.isArray(group)) entryConfig = getMultiPageConfig(group);
else if (group.inputPath.endsWith('.css'))
else if (
group.type === 'content-script-style' ||
group.type === 'unlisted-style'
)
entryConfig = getCssConfig(group);
else entryConfig = getLibModeConfig(group);

Expand Down
Loading