diff --git a/README.md b/README.md index 9b20dba..e45200b 100644 --- a/README.md +++ b/README.md @@ -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, }, }) ``` diff --git a/index.d.ts b/index.d.ts index 8e229de..15d9589 100644 --- a/index.d.ts +++ b/index.d.ts @@ -9,6 +9,7 @@ interface StylusOptions { include?: string[] define?: ([string, any, boolean?])[] use?: ((styl: any) => void)[] + includeCss?: boolean } declare const stylusLoader: (options: PluginOptions) => Plugin diff --git a/test/e2e.js b/test/e2e.js index efaca9f..7cf188c 100644 --- a/test/e2e.js +++ b/test/e2e.js @@ -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', @@ -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: [