Skip to content

Commit

Permalink
test: add tailwindcss bundle false test case (#699)
Browse files Browse the repository at this point in the history
  • Loading branch information
SoonIter authored Jan 21, 2025
1 parent f409e4d commit cc6866d
Show file tree
Hide file tree
Showing 8 changed files with 87 additions and 0 deletions.
6 changes: 6 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions tests/integration/style/tailwindcss/bundle-false/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"name": "tailwindcss-bundle-false-test",
"private": true,
"devDependencies": {
"tailwindcss": "^3.4.17"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
const path = require('node:path');

export default {
plugins: {
tailwindcss: {
config: path.join(__dirname, './tailwind.config.cjs'),
},
},
};
19 changes: 19 additions & 0 deletions tests/integration/style/tailwindcss/bundle-false/rslib.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { defineConfig } from '@rslib/core';
import { generateBundleCjsConfig, generateBundleEsmConfig } from 'test-helper';

export default defineConfig({
lib: [
generateBundleEsmConfig({
bundle: false,
}),
generateBundleCjsConfig({
bundle: false,
}),
],
tools: {
lightningcssLoader: false,
},
output: {
target: 'web',
},
});
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
@tailwind utilities;
7 changes: 7 additions & 0 deletions tests/integration/style/tailwindcss/bundle-false/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import './index.css';

const div = document.createElement('div');

div.classList.add('text-3xl', 'font-bold', 'underline', 'alert');

export { div };
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
const path = require('node:path');

/** @type {import('tailwindcss').Config} */
module.exports = {
content: [path.join(__dirname, './src/**/*.{html,js,ts,jsx,tsx}')],
theme: {
extend: {},
},
plugins: [],
};
28 changes: 28 additions & 0 deletions tests/integration/style/tailwindcss/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,31 @@ test('should extract css when using tailwindcss successfully in bundle', async (
'.underline {',
]);
});

test('should extract css when using tailwindcss successfully in bundleless', async () => {
const fixturePath = join(__dirname, 'bundle-false');
const { contents } = await buildAndGetResults({ fixturePath, type: 'css' });
const esmFiles = Object.keys(contents.esm);
expect(esmFiles).toMatchInlineSnapshot(`
[
"<ROOT>/tests/integration/style/tailwindcss/bundle-false/dist/esm/index.css",
]
`);
expectFileContainContent(contents.esm, 'index.css', [
'.text-3xl {',
'.font-bold {',
'.underline {',
]);

const cjsFiles = Object.keys(contents.cjs);
expect(cjsFiles).toMatchInlineSnapshot(`
[
"<ROOT>/tests/integration/style/tailwindcss/bundle-false/dist/cjs/index.css",
]
`);
expectFileContainContent(contents.cjs, 'index.css', [
'.text-3xl {',
'.font-bold {',
'.underline {',
]);
});

0 comments on commit cc6866d

Please sign in to comment.