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
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ export function createCssPlugin(options: CssPluginOptions): Plugin {
const postcssProcessor = postcss();
if (options.tailwindConfiguration) {
const tailwind = await import(options.tailwindConfiguration.package);
postcssProcessor.use(tailwind({ config: options.tailwindConfiguration.file }));
postcssProcessor.use(tailwind.default({ config: options.tailwindConfiguration.file }));
}
if (!skipAutoprefixer) {
postcssProcessor.use(autoprefixer);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,8 @@ export async function normalizeOptions(
let tailwindConfiguration: { file: string; package: string } | undefined;
const tailwindConfigurationPath = findTailwindConfigurationFile(workspaceRoot, projectRoot);
if (tailwindConfigurationPath) {
const resolver = createRequire(projectRoot);
// Create a node resolver at the project root as a directory
const resolver = createRequire(projectRoot + '/');
try {
tailwindConfiguration = {
file: tailwindConfigurationPath,
Expand Down
2 changes: 1 addition & 1 deletion tests/legacy-cli/e2e.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ def _e2e_suite(name, runner, type, data, toolchain_name = "", toolchain = None):
data = data,
toolchain = toolchain,
shard_count = TEST_SHARD_COUNT,
templated_args = [
templated_args = args + [
"--glob=%s" % _to_glob(tests) if tests else "",
"--ignore=%s" % _to_glob(ignore) if ignore else "",
],
Expand Down
27 changes: 21 additions & 6 deletions tests/legacy-cli/e2e/tests/build/styles/tailwind-v2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,14 @@ export default async function () {
}

// Tailwind directives should be unprocessed with missing package
await expectFileToMatch('dist/test-project/styles.css', '@tailwind base; @tailwind components;');
await expectFileToMatch('dist/test-project/main.js', '@tailwind base; @tailwind components;');
await expectFileToMatch(
'dist/test-project/styles.css',
/@tailwind base;\s+@tailwind components;/,
);
await expectFileToMatch(
'dist/test-project/main.js',
/@tailwind base;(?:\\n|\s*)@tailwind components;/,
);

// Install Tailwind
await installPackage('tailwindcss@2');
Expand All @@ -37,19 +43,28 @@ export default async function () {
await expectFileToMatch('dist/test-project/styles.css', /::placeholder/);
await expectFileToMatch('dist/test-project/main.js', /::placeholder/);
await expectToFail(() =>
expectFileToMatch('dist/test-project/styles.css', '@tailwind base; @tailwind components;'),
expectFileToMatch('dist/test-project/styles.css', /@tailwind base;\s+@tailwind components;/),
);
await expectToFail(() =>
expectFileToMatch('dist/test-project/main.js', '@tailwind base; @tailwind components;'),
expectFileToMatch(
'dist/test-project/main.js',
/@tailwind base;(?:\\n|\s*)@tailwind components;/,
),
);

// Remove configuration file
await deleteFile('tailwind.config.js');

// Ensure Tailwind is disabled when no configuration file is present
await ng('build', '--configuration=development');
await expectFileToMatch('dist/test-project/styles.css', '@tailwind base; @tailwind components;');
await expectFileToMatch('dist/test-project/main.js', '@tailwind base; @tailwind components;');
await expectFileToMatch(
'dist/test-project/styles.css',
/@tailwind base;\s+@tailwind components;/,
);
await expectFileToMatch(
'dist/test-project/main.js',
/@tailwind base;(?:\\n|\s*)@tailwind components;/,
);

// Uninstall Tailwind
await uninstallPackage('tailwindcss');
Expand Down
2 changes: 1 addition & 1 deletion tests/legacy-cli/e2e/tests/build/styles/tailwind-v3-cjs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export default async function () {
// Check for Tailwind output
await expectFileToMatch('dist/test-project/styles.css', /::placeholder/);
await expectToFail(() =>
expectFileToMatch('dist/test-project/styles.css', '@tailwind base; @tailwind components;'),
expectFileToMatch('dist/test-project/styles.css', /@tailwind base;\s+@tailwind components;/),
);

// Uninstall Tailwind
Expand Down
27 changes: 21 additions & 6 deletions tests/legacy-cli/e2e/tests/build/styles/tailwind-v3.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,14 @@ export default async function () {
}

// Tailwind directives should be unprocessed with missing package
await expectFileToMatch('dist/test-project/styles.css', '@tailwind base; @tailwind components;');
await expectFileToMatch('dist/test-project/main.js', '@tailwind base; @tailwind components;');
await expectFileToMatch(
'dist/test-project/styles.css',
/@tailwind base;\s+@tailwind components;/,
);
await expectFileToMatch(
'dist/test-project/main.js',
/@tailwind base;(?:\\n|\s*)@tailwind components;/,
);

// Install Tailwind
await installPackage('tailwindcss@3');
Expand All @@ -37,19 +43,28 @@ export default async function () {
await expectFileToMatch('dist/test-project/styles.css', /::placeholder/);
await expectFileToMatch('dist/test-project/main.js', /::placeholder/);
await expectToFail(() =>
expectFileToMatch('dist/test-project/styles.css', '@tailwind base; @tailwind components;'),
expectFileToMatch('dist/test-project/styles.css', /@tailwind base;\s+@tailwind components;/),
);
await expectToFail(() =>
expectFileToMatch('dist/test-project/main.js', '@tailwind base; @tailwind components;'),
expectFileToMatch(
'dist/test-project/main.js',
/@tailwind base;(?:\\n|\s*)@tailwind components;/,
),
);

// Remove configuration file
await deleteFile('tailwind.config.js');

// Ensure Tailwind is disabled when no configuration file is present
await ng('build', '--configuration=development');
await expectFileToMatch('dist/test-project/styles.css', '@tailwind base; @tailwind components;');
await expectFileToMatch('dist/test-project/main.js', '@tailwind base; @tailwind components;');
await expectFileToMatch(
'dist/test-project/styles.css',
/@tailwind base;\s+@tailwind components;/,
);
await expectFileToMatch(
'dist/test-project/main.js',
/@tailwind base;(?:\\n|\s*)@tailwind components;/,
);

// Uninstall Tailwind
await uninstallPackage('tailwindcss');
Expand Down