Skip to content

Commit cc6866d

Browse files
authored
test: add tailwindcss bundle false test case (#699)
1 parent f409e4d commit cc6866d

File tree

8 files changed

+87
-0
lines changed

8 files changed

+87
-0
lines changed

pnpm-lock.yaml

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"name": "tailwindcss-bundle-false-test",
3+
"private": true,
4+
"devDependencies": {
5+
"tailwindcss": "^3.4.17"
6+
}
7+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
const path = require('node:path');
2+
3+
export default {
4+
plugins: {
5+
tailwindcss: {
6+
config: path.join(__dirname, './tailwind.config.cjs'),
7+
},
8+
},
9+
};
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import { defineConfig } from '@rslib/core';
2+
import { generateBundleCjsConfig, generateBundleEsmConfig } from 'test-helper';
3+
4+
export default defineConfig({
5+
lib: [
6+
generateBundleEsmConfig({
7+
bundle: false,
8+
}),
9+
generateBundleCjsConfig({
10+
bundle: false,
11+
}),
12+
],
13+
tools: {
14+
lightningcssLoader: false,
15+
},
16+
output: {
17+
target: 'web',
18+
},
19+
});
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
@tailwind utilities;
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import './index.css';
2+
3+
const div = document.createElement('div');
4+
5+
div.classList.add('text-3xl', 'font-bold', 'underline', 'alert');
6+
7+
export { div };
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
const path = require('node:path');
2+
3+
/** @type {import('tailwindcss').Config} */
4+
module.exports = {
5+
content: [path.join(__dirname, './src/**/*.{html,js,ts,jsx,tsx}')],
6+
theme: {
7+
extend: {},
8+
},
9+
plugins: [],
10+
};

tests/integration/style/tailwindcss/index.test.ts

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,31 @@ test('should extract css when using tailwindcss successfully in bundle', async (
3030
'.underline {',
3131
]);
3232
});
33+
34+
test('should extract css when using tailwindcss successfully in bundleless', async () => {
35+
const fixturePath = join(__dirname, 'bundle-false');
36+
const { contents } = await buildAndGetResults({ fixturePath, type: 'css' });
37+
const esmFiles = Object.keys(contents.esm);
38+
expect(esmFiles).toMatchInlineSnapshot(`
39+
[
40+
"<ROOT>/tests/integration/style/tailwindcss/bundle-false/dist/esm/index.css",
41+
]
42+
`);
43+
expectFileContainContent(contents.esm, 'index.css', [
44+
'.text-3xl {',
45+
'.font-bold {',
46+
'.underline {',
47+
]);
48+
49+
const cjsFiles = Object.keys(contents.cjs);
50+
expect(cjsFiles).toMatchInlineSnapshot(`
51+
[
52+
"<ROOT>/tests/integration/style/tailwindcss/bundle-false/dist/cjs/index.css",
53+
]
54+
`);
55+
expectFileContainContent(contents.cjs, 'index.css', [
56+
'.text-3xl {',
57+
'.font-bold {',
58+
'.underline {',
59+
]);
60+
});

0 commit comments

Comments
 (0)