Skip to content

Commit

Permalink
fix: 🐛 pass less @imports as dependencies to svelte
Browse files Browse the repository at this point in the history
  • Loading branch information
kaisermann committed Jul 1, 2019
1 parent 9dd53d8 commit 55e9d28
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 10 deletions.
22 changes: 12 additions & 10 deletions src/transformers/less.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
const less = require('less/lib/less-node')

module.exports = ({ content, filename, options }) => {
return less
.render(content, {
sourceMap: {},
...options,
})
.then(output => ({
code: output.css,
map: output.map,
}))
module.exports = async ({ content, filename, options }) => {
const { css, map, imports } = await less.render(content, {
sourceMap: {},
filename,
...options,
})

return {
code: css,
map,
dependencies: imports,
}
}
14 changes: 14 additions & 0 deletions test/transformers/less.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
const { resolve } = require('path')
const getAutoPreprocess = require('../../src')
const { preprocess } = require('../utils.js')

describe('transformer - less', () => {
it('should return @imported files as dependencies', async () => {
const template = `<style lang="less">@import "fixtures/style.less";</style>`
const opts = getAutoPreprocess()
const preprocessed = await preprocess(template, opts)
expect(preprocessed.dependencies).toContain(
resolve(__dirname, '..', 'fixtures', 'style.less'),
)
})
})

0 comments on commit 55e9d28

Please sign in to comment.