diff --git a/src/index.ts b/src/index.ts index fc1cbc0..391a572 100644 --- a/src/index.ts +++ b/src/index.ts @@ -735,7 +735,12 @@ function transformCss(ast: any, { env }: TransformerContext) { // based on postcss-value parser. try { let parser = base.parsers.css - let root = parser.parse(`@import ${params};`, env.options) + + let root = parser.parse(`@import ${params};`, { + // We can't pass env.options directly because css.parse overwrites + // options.originalText which is used during the printing phase + ...env.options, + }) return root.nodes[0].params } catch (err) { diff --git a/tests/tests.ts b/tests/tests.ts index 410e9c2..b7db3df 100644 --- a/tests/tests.ts +++ b/tests/tests.ts @@ -46,7 +46,20 @@ let css: TestEntry[] = [ [`@config "./file.js";`, `@config './file.js';`], [`@source "./file.js";`, `@source './file.js';`], [`@source not "./file.js";`, `@source not './file.js';`], - [`@source inline("./file.js");`, `@source inline('./file.js');`], + [`@source inline("flex");`, `@source inline('flex');`], + + [ + `@import "tailwindcss";\n\n@import "./theme.css";\n\n@source "./file.js";\n\n.foo {\n color: red;\n}`, + `@import 'tailwindcss';\n\n@import './theme.css';\n\n@source './file.js';\n\n.foo {\n color: red;\n}`, + ], + [ + `@import "tailwindcss";\n\n@import "./theme.css";\n\n@plugin "./file.js";\n\n.foo {\n color: red;\n}`, + `@import 'tailwindcss';\n\n@import './theme.css';\n\n@plugin './file.js';\n\n.foo {\n color: red;\n}`, + ], + [ + `@import "tailwindcss";\n\n@import "./theme.css";\n\n@config "./file.js";\n\n.foo {\n color: red;\n}`, + `@import 'tailwindcss';\n\n@import './theme.css';\n\n@config './file.js';\n\n.foo {\n color: red;\n}`, + ], ] export let javascript: TestEntry[] = [