Skip to content
Open
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
1,140 changes: 726 additions & 414 deletions package-lock.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
"@vitest/coverage-v8": "^4.1.0",
"memfs": "^4.57.1",
"prettier": "^3.8.1",
"sass": "^1.102.0",
"typescript": "^5.9.3",
"vite": "^8.0.1",
"vitest": "^4.1.0"
Expand Down
4 changes: 4 additions & 0 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,10 @@ export function createAliases(
find: "EXT:" + extension.extensionKey,
replacement,
});
aliases.push({
find: "ext:" + extension.extensionKey,
replacement,
});
}
return aliases;
}, []);
Expand Down
11 changes: 10 additions & 1 deletion tests/integration/manifest-expected.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,17 @@
"assets/Main-VWk4xp3e.css"
]
},
"vendor/praetorius/test-extension/Resources/Private/Scss.entry.ts": {
"file": "assets/Scss.entry-CptVgpj7.js",
"name": "Scss.entry",
"src": "vendor/praetorius/test-extension/Resources/Private/Scss.entry.ts",
"isEntry": true,
"css": [
"assets/Scss-BpwiChWd.css"
]
},
"vendor/test-vendor/vendor-extension/Resources/Private/Vendor.entry.ts": {
"file": "assets/Vendor.entry-Bk2RJPqq.js",
"file": "assets/Vendor.entry-4M5qqhJ-.js",
"name": "Vendor.entry",
"src": "vendor/test-vendor/vendor-extension/Resources/Private/Vendor.entry.ts",
"isEntry": true,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
import "EXT:test_extension/Resources/Private/Scss/Main.scss";
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
@import "EXT:test_extension/Resources/Private/Scss/partial";

.scss-main {
background: green;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.partial {
color: blue;
}
38 changes: 27 additions & 11 deletions tests/integration/typo3extension.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,15 @@ test("vite build works for TYPO3 extension", async () => {
root,
plugins: [typo3({ target: "extension" })],
build: {
lib: {
cssFileName: "style",
},
cssCodeSplit: true,
},
});

expect(output).toHaveLength(2);

const esmOutput = output[0];

expect(esmOutput.output).toHaveLength(3);
expect(esmOutput.output).toHaveLength(5);
expect(esmOutput.output[0].fileName).toMatchInlineSnapshot(
`"Alt.entry.js"`,
);
Expand All @@ -41,14 +39,23 @@ test("vite build works for TYPO3 extension", async () => {
//#endregion
"
`);
expect(esmOutput.output[2].fileName).toMatchInlineSnapshot(`"style.css"`);
expect(esmOutput.output[2].source).toMatchInlineSnapshot(`
expect(esmOutput.output[2].fileName).toMatchInlineSnapshot(
`"Scss.entry.js"`,
);
expect(esmOutput.output[2].code).toMatchInlineSnapshot(`""`);
expect(esmOutput.output[3].fileName).toMatchInlineSnapshot(`"Main.css"`);
expect(esmOutput.output[3].source).toMatchInlineSnapshot(`
"body{background:red}
/*$vite$:1*/"
"
`);
expect(esmOutput.output[4].fileName).toMatchInlineSnapshot(`"Scss.css"`);
expect(esmOutput.output[4].source).toMatchInlineSnapshot(`
".partial{color:#00f}.scss-main{background:green}
"
`);

const cjsOutput = output[1];
expect(cjsOutput.output).toHaveLength(3);
expect(cjsOutput.output).toHaveLength(5);
expect(cjsOutput.output[0].fileName).toMatchInlineSnapshot(
`"Alt.entry.cjs"`,
);
Expand All @@ -61,9 +68,18 @@ test("vite build works for TYPO3 extension", async () => {
expect(cjsOutput.output[1].code).toMatchInlineSnapshot(
`"console.log(\`Main.ts\`);"`,
);
expect(cjsOutput.output[2].fileName).toMatchInlineSnapshot(`"style.css"`);
expect(cjsOutput.output[2].source).toMatchInlineSnapshot(`
expect(cjsOutput.output[2].fileName).toMatchInlineSnapshot(
`"Scss.entry.cjs"`,
);
expect(cjsOutput.output[2].code).toMatchInlineSnapshot(`""`);
expect(cjsOutput.output[3].fileName).toMatchInlineSnapshot(`"Main.css"`);
expect(cjsOutput.output[3].source).toMatchInlineSnapshot(`
"body{background:red}
/*$vite$:1*/"
"
`);
expect(cjsOutput.output[4].fileName).toMatchInlineSnapshot(`"Scss.css"`);
expect(cjsOutput.output[4].source).toMatchInlineSnapshot(`
".partial{color:#00f}.scss-main{background:green}
"
`);
});
23 changes: 18 additions & 5 deletions tests/integration/typo3project.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ test("vite build works for TYPO3 project", async () => {
(a, b) => (a.fileName < b.fileName ? -1 : 1),
);

expect(sortedOutput).toHaveLength(6);
expect(sortedOutput).toHaveLength(8);

expect((sortedOutput[0] as OutputAsset).fileName).toBe(
".vite/manifest.json",
Expand Down Expand Up @@ -50,17 +50,30 @@ test("vite build works for TYPO3 project", async () => {
);

expect((sortedOutput[4] as OutputAsset).fileName).toMatchInlineSnapshot(
`"assets/Vendor-DE25tVp9.css"`,
`"assets/Scss-BpwiChWd.css"`,
);
expect((sortedOutput[4] as OutputAsset).source).toMatchInlineSnapshot(`
"body{background:#00f}
".partial{color:#00f}.scss-main{background:green}
"
`);

expect((sortedOutput[5] as OutputChunk).fileName).toMatchInlineSnapshot(
`"assets/Vendor.entry-Bk2RJPqq.js"`,
`"assets/Scss.entry-CptVgpj7.js"`,
);
expect((sortedOutput[5] as OutputChunk).code).toMatchInlineSnapshot(`""`);

expect((sortedOutput[6] as OutputAsset).fileName).toMatchInlineSnapshot(
`"assets/Vendor-DE25tVp9.css"`,
);
expect((sortedOutput[6] as OutputAsset).source).toMatchInlineSnapshot(`
"body{background:#00f}
"
`);

expect((sortedOutput[7] as OutputChunk).fileName).toMatchInlineSnapshot(
`"assets/Vendor.entry-4M5qqhJ-.js"`,
);
expect((sortedOutput[5] as OutputChunk).code).toMatchInlineSnapshot(
expect((sortedOutput[7] as OutputChunk).code).toMatchInlineSnapshot(
`"console.log(\`Vendor.ts\`);"`,
);
});
20 changes: 20 additions & 0 deletions tests/unit/addAliases.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ describe("addAliases", () => {
find: "EXT:test_extension",
replacement: "/path/to/dummy/extension1",
},
{
find: "ext:test_extension",
replacement: "/path/to/dummy/extension1",
},
]);
});
test("existing aliases as object", () => {
Expand All @@ -47,6 +51,10 @@ describe("addAliases", () => {
find: "EXT:test_extension",
replacement: "/path/to/dummy/extension1",
},
{
find: "ext:test_extension",
replacement: "/path/to/dummy/extension1",
},
]);
});
test("existing aliases as array", () => {
Expand Down Expand Up @@ -92,6 +100,10 @@ describe("addAliases", () => {
find: "EXT:test_extension",
replacement: "/path/to/dummy/extension1",
},
{
find: "ext:test_extension",
replacement: "/path/to/dummy/extension1",
},
]);
});
test("no double slashes in added alias paths", () => {
Expand All @@ -112,6 +124,10 @@ describe("addAliases", () => {
find: "EXT:test_extension",
replacement: "/path/to/dummy/extension1",
},
{
find: "ext:test_extension",
replacement: "/path/to/dummy/extension1",
},
]);
});
test("set no aliases", () => {
Expand Down Expand Up @@ -167,6 +183,10 @@ describe("addAliases", () => {
find: "EXT:test_extension",
replacement: "/path/to/dummy/extension1",
},
{
find: "ext:test_extension",
replacement: "/path/to/dummy/extension1",
},
]);
});
});
2 changes: 1 addition & 1 deletion tests/unit/outputDebugInformation.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ describe("outputDebugInformation", () => {
2,
"The following aliases have been defined: " +
colors.green(
"@test_extension1, EXT:test_extension1, @test_extension2, EXT:test_extension2",
"@test_extension1, EXT:test_extension1, ext:test_extension1, @test_extension2, EXT:test_extension2, ext:test_extension2",
),
{ timestamp: true },
);
Expand Down