rollup-plugin-bundle-scss
Advanced tools
Comparing version 0.1.0 to 0.1.1
@@ -10,3 +10,3 @@ 'use strict'; | ||
function bundleScss({ output } = {}) { | ||
function bundleScss({ output, exclusive = true } = {}) { | ||
const files = []; | ||
@@ -18,3 +18,5 @@ return { | ||
files.push({ id, content: source }); | ||
return { code: `export default ${JSON.stringify(source)}` }; | ||
if (exclusive) { | ||
return { code: `export default ${JSON.stringify(source)}` }; | ||
} | ||
} | ||
@@ -36,4 +38,4 @@ if (/\.vue$/.test(id)) { | ||
const outputPath = path.resolve( | ||
path.dirname(opts.file), | ||
output || `${path.parse(opts.file).name}.scss`, | ||
opts.file ? path.dirname(opts.file) : opts.dir, | ||
output || `${opts.file ? path.parse(opts.file).name : 'index'}.scss`, | ||
); | ||
@@ -40,0 +42,0 @@ await fs.promises.mkdir(path.dirname(outputPath), { recursive: true }); |
10
index.js
@@ -6,3 +6,3 @@ import { promises as fs } from 'fs'; | ||
export default function bundleScss({ output } = {}) { | ||
export default function bundleScss({ output, exclusive = true } = {}) { | ||
const files = []; | ||
@@ -14,3 +14,5 @@ return { | ||
files.push({ id, content: source }); | ||
return { code: `export default ${JSON.stringify(source)}` }; | ||
if (exclusive) { | ||
return { code: `export default ${JSON.stringify(source)}` }; | ||
} | ||
} | ||
@@ -32,4 +34,4 @@ if (/\.vue$/.test(id)) { | ||
const outputPath = path.resolve( | ||
path.dirname(opts.file), | ||
output || `${path.parse(opts.file).name}.scss`, | ||
opts.file ? path.dirname(opts.file) : opts.dir, | ||
output || `${opts.file ? path.parse(opts.file).name : 'index'}.scss`, | ||
); | ||
@@ -36,0 +38,0 @@ await fs.mkdir(path.dirname(outputPath), { recursive: true }); |
{ | ||
"name": "rollup-plugin-bundle-scss", | ||
"version": "0.1.0", | ||
"version": "0.1.1", | ||
"description": "Rollup .scss imports into one bundled .scss file", | ||
@@ -39,14 +39,15 @@ "main": "dist/index.js", | ||
"dependencies": { | ||
"scss-bundle": "^3.0.2", | ||
"vue-template-compiler": "^2.6.10" | ||
"scss-bundle": "^3.1.2", | ||
"vue-template-compiler": "^2.6.11" | ||
}, | ||
"devDependencies": { | ||
"eslint": "^6.6.0", | ||
"eslint-config-airbnb-base": "^14.0.0", | ||
"eslint-plugin-import": "^2.18.2", | ||
"jest": "^24.9.0", | ||
"rollup": "^1.27.0", | ||
"eslint": "^7.3.1", | ||
"eslint-config-airbnb-base": "^14.2.0", | ||
"eslint-plugin-import": "^2.21.2", | ||
"jest": "^26.1.0", | ||
"rollup": "^2.18.0", | ||
"rollup-plugin-commonjs": "^10.1.0", | ||
"rollup-plugin-vue": "^5.1.2" | ||
"rollup-plugin-postcss": "^3.1.2", | ||
"rollup-plugin-vue": "^5.1.9" | ||
} | ||
} |
@@ -12,2 +12,4 @@ # rollup-plugin-bundle-scss | ||
It dependence on [scss-bundle](https://github.com/reactway/scss-bundle). | ||
## Installation | ||
@@ -61,1 +63,37 @@ | ||
``` | ||
Using with [rollup-plugin-postcss](https://github.com/egoist/rollup-plugin-postcss): | ||
```js | ||
import bundleScss from 'rollup-plugin-bundle-scss'; | ||
import postcss from 'rollup-plugin-postcss'; | ||
export default { | ||
input: 'src/index.js', | ||
output: { | ||
file: 'dist/index.js', | ||
format: 'esm', | ||
}, | ||
plugins: [ | ||
// put it before postcss(), and set exclusive to false | ||
bundleScss({ exclusive: false }), | ||
postcss({ | ||
// ... | ||
}), | ||
], | ||
}; | ||
``` | ||
## API | ||
```js | ||
bundleScss({ | ||
// where to output bundled SCSS file | ||
output: String, | ||
// Whether SCSS file is exclusive to rollup-plugin-bundle-scss. | ||
// Defalut value: true | ||
// Set it to false when there're other plugin to handle SCSS file after bundleScss() | ||
exclusive: Boolean, | ||
}) | ||
``` |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
8435
89
98
8
+ Added@types/node@22.10.1(transitive)
+ Addedundici-types@6.20.0(transitive)
- Removed@types/node@22.9.3(transitive)
- Removedundici-types@6.19.8(transitive)
Updatedscss-bundle@^3.1.2