-
-
Notifications
You must be signed in to change notification settings - Fork 194
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add
webpackImporter
option (#377)
- Loading branch information
1 parent
919c3b9
commit 12dca5b
Showing
9 changed files
with
212 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`webpackImporter option not specify webpackImporter option: css 1`] = ` | ||
"@import \\"~some/css.css\\"; | ||
@import \\"~some/css.css\\"; | ||
#it-works { | ||
color: hotpink; | ||
} | ||
.modules-dir-some-module, | ||
#it-works { | ||
background: hotpink; | ||
} | ||
#it-works { | ||
margin: 10px; | ||
} | ||
" | ||
`; | ||
|
||
exports[`webpackImporter option not specify webpackImporter option: errors 1`] = `Array []`; | ||
|
||
exports[`webpackImporter option not specify webpackImporter option: warnings 1`] = `Array []`; | ||
|
||
exports[`webpackImporter option webpackImporter option is false: errors 1`] = ` | ||
Array [ | ||
"ModuleBuildError: Module build failed (from \`replaced original path\`): | ||
", | ||
] | ||
`; | ||
|
||
exports[`webpackImporter option webpackImporter option is false: warnings 1`] = `Array []`; | ||
|
||
exports[`webpackImporter option webpackImporter option is true: css 1`] = ` | ||
"@import \\"~some/css.css\\"; | ||
@import \\"~some/css.css\\"; | ||
#it-works { | ||
color: hotpink; | ||
} | ||
.modules-dir-some-module, | ||
#it-works { | ||
background: hotpink; | ||
} | ||
#it-works { | ||
margin: 10px; | ||
} | ||
" | ||
`; | ||
|
||
exports[`webpackImporter option webpackImporter option is true: errors 1`] = `Array []`; | ||
|
||
exports[`webpackImporter option webpackImporter option is true: warnings 1`] = `Array []`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import { | ||
compile, | ||
getCodeFromBundle, | ||
getCodeFromLess, | ||
getCompiler, | ||
getErrors, | ||
getWarnings, | ||
} from './helpers'; | ||
|
||
describe('webpackImporter option', () => { | ||
it('not specify webpackImporter option', async () => { | ||
const testId = './import-webpack.less'; | ||
const compiler = getCompiler(testId); | ||
const stats = await compile(compiler); | ||
const codeFromBundle = getCodeFromBundle(stats, compiler); | ||
const codeFromLess = await getCodeFromLess(testId); | ||
|
||
expect(codeFromBundle.css).toBe(codeFromLess.css); | ||
expect(codeFromBundle.css).toMatchSnapshot('css'); | ||
expect(getWarnings(stats)).toMatchSnapshot('warnings'); | ||
expect(getErrors(stats)).toMatchSnapshot('errors'); | ||
}); | ||
|
||
it('webpackImporter option is true', async () => { | ||
const testId = './import-webpack.less'; | ||
const compiler = getCompiler(testId, { | ||
webpackImporter: true, | ||
}); | ||
const stats = await compile(compiler); | ||
const codeFromBundle = getCodeFromBundle(stats, compiler); | ||
const codeFromLess = await getCodeFromLess(testId); | ||
|
||
expect(codeFromBundle.css).toBe(codeFromLess.css); | ||
expect(codeFromBundle.css).toMatchSnapshot('css'); | ||
expect(getWarnings(stats)).toMatchSnapshot('warnings'); | ||
expect(getErrors(stats)).toMatchSnapshot('errors'); | ||
}); | ||
|
||
it('webpackImporter option is false', async () => { | ||
const testId = './import-webpack.less'; | ||
const compiler = getCompiler(testId, { | ||
webpackImporter: false, | ||
}); | ||
const stats = await compile(compiler); | ||
|
||
expect(getWarnings(stats)).toMatchSnapshot('warnings'); | ||
expect(getErrors(stats)).toMatchSnapshot('errors'); | ||
}); | ||
}); |