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
7 changes: 6 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
15 changes: 14 additions & 1 deletion tests/tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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[] = [
Expand Down