Skip to content

Commit

Permalink
feat(#9): add includeCss option
Browse files Browse the repository at this point in the history
  • Loading branch information
ym-project committed Aug 20, 2021
1 parent 21b257d commit b291a68
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 1 deletion.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,12 @@ stylusLoader({
/** The third argument allows to insert raw data */
['BG_IMAGE', 'https://domain.com/image.jpeg', true],
],

/**
* Include css files.
* @type {boolean}
*/
includeCss: false,
},
})
```
1 change: 1 addition & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ interface StylusOptions {
include?: string[]
define?: ([string, any, boolean?])[]
use?: ((styl: any) => void)[]
includeCss?: boolean
}

declare const stylusLoader: (options: PluginOptions) => Plugin
Expand Down
48 changes: 47 additions & 1 deletion test/e2e.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ test('Check stylus "@import" keyword with css file. Should be without changes.',
t.truthy(outputFiles[1].text.includes('@import "./file.css";'))
})

test('Check stylus "@import" keyword with stylus file. Should insert required file.', async t => {
test('Check stylus "@import" keyword with stylus file. Should insert imported file.', async t => {
const {outputFiles} = await build({
entryPoints: [
'./test/fixtures/import-stylus/entry.js',
Expand Down Expand Up @@ -202,6 +202,52 @@ test('Check "use" option.', async t => {
)))
})

test('Check "includeCss" "true" option.', async t => {
const {outputFiles} = await build({
entryPoints: [
'./test/fixtures/import-css/entry.js',
],
bundle: true,
outdir: '.',
write: false,
plugins: [
stylusLoader({
stylusOptions: {
includeCss: true,
},
}),
],
})

t.truthy(outputFiles[1].path.includes('entry.css'))
t.truthy(outputFiles[1].text.includes(''.concat(
'.class {\n',
' width: 100%;\n',
'}',
)))
})

test('Check "includeCss" "false" option.', async t => {
const {outputFiles} = await build({
entryPoints: [
'./test/fixtures/import-css/entry.js',
],
bundle: true,
outdir: '.',
write: false,
plugins: [
stylusLoader({
stylusOptions: {
includeCss: false,
},
}),
],
})

t.truthy(outputFiles[1].path.includes('entry.css'))
t.truthy(outputFiles[1].text.includes('@import "./file.css";'))
})

test('Check css "inline" sourcemaps', async t => {
const {outputFiles} = await build({
entryPoints: [
Expand Down

0 comments on commit b291a68

Please sign in to comment.