rollup-plugin-bundle-scss
Advanced tools
Comparing version 0.1.1 to 0.1.2
'use strict'; | ||
function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; } | ||
var fs = require('fs'); | ||
var path = _interopDefault(require('path')); | ||
var compiler = _interopDefault(require('vue-template-compiler')); | ||
var path = require('path'); | ||
var compiler = require('vue-template-compiler'); | ||
var scssBundle = require('scss-bundle'); | ||
function bundleScss({ output, exclusive = true } = {}) { | ||
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } | ||
var path__default = /*#__PURE__*/_interopDefaultLegacy(path); | ||
var compiler__default = /*#__PURE__*/_interopDefaultLegacy(compiler); | ||
function bundleScss({ output, exclusive = true, bundlerOptions = {} } = {}) { | ||
const files = []; | ||
const { | ||
project = null, | ||
dedupeGlobs = [], | ||
includePaths = [], | ||
ignoreImports = [], | ||
} = bundlerOptions; | ||
return { | ||
@@ -22,3 +31,3 @@ name: 'bundle-scss', | ||
if (/\.vue$/.test(id)) { | ||
const { styles } = compiler.parseComponent(source); | ||
const { styles } = compiler__default['default'].parseComponent(source); | ||
files.push( | ||
@@ -36,12 +45,12 @@ ...styles | ||
async generateBundle(opts) { | ||
const outputPath = path.resolve( | ||
opts.file ? path.dirname(opts.file) : opts.dir, | ||
output || `${opts.file ? path.parse(opts.file).name : 'index'}.scss`, | ||
const outputPath = path__default['default'].resolve( | ||
opts.file ? path__default['default'].dirname(opts.file) : opts.dir, | ||
output || `${opts.file ? path__default['default'].parse(opts.file).name : 'index'}.scss`, | ||
); | ||
await fs.promises.mkdir(path.dirname(outputPath), { recursive: true }); | ||
await fs.promises.mkdir(path__default['default'].dirname(outputPath), { recursive: true }); | ||
const entryContent = files.map((file) => `@import "${file.id}";`).join('\n'); | ||
await fs.promises.writeFile(outputPath, entryContent); | ||
const registry = Object.assign({}, ...files.map((file) => ({ [file.id]: file.content }))); | ||
const bundler = new scssBundle.Bundler(registry); | ||
const result = await bundler.bundle(outputPath); | ||
const bundler = new scssBundle.Bundler(registry, project); | ||
const result = await bundler.bundle(outputPath, dedupeGlobs, includePaths, ignoreImports); | ||
await fs.promises.writeFile(outputPath, result.bundledContent); | ||
@@ -48,0 +57,0 @@ }, |
12
index.js
@@ -6,4 +6,10 @@ import { promises as fs } from 'fs'; | ||
export default function bundleScss({ output, exclusive = true } = {}) { | ||
export default function bundleScss({ output, exclusive = true, bundlerOptions = {} } = {}) { | ||
const files = []; | ||
const { | ||
project = null, | ||
dedupeGlobs = [], | ||
includePaths = [], | ||
ignoreImports = [], | ||
} = bundlerOptions; | ||
return { | ||
@@ -40,4 +46,4 @@ name: 'bundle-scss', | ||
const registry = Object.assign({}, ...files.map((file) => ({ [file.id]: file.content }))); | ||
const bundler = new Bundler(registry); | ||
const result = await bundler.bundle(outputPath); | ||
const bundler = new Bundler(registry, project); | ||
const result = await bundler.bundle(outputPath, dedupeGlobs, includePaths, ignoreImports); | ||
await fs.writeFile(outputPath, result.bundledContent); | ||
@@ -44,0 +50,0 @@ }, |
{ | ||
"name": "rollup-plugin-bundle-scss", | ||
"version": "0.1.1", | ||
"version": "0.1.2", | ||
"description": "Rollup .scss imports into one bundled .scss file", | ||
@@ -40,14 +40,14 @@ "main": "dist/index.js", | ||
"scss-bundle": "^3.1.2", | ||
"vue-template-compiler": "^2.6.11" | ||
"vue-template-compiler": "^2.6.12" | ||
}, | ||
"devDependencies": { | ||
"eslint": "^7.3.1", | ||
"eslint": "^7.11.0", | ||
"eslint-config-airbnb-base": "^14.2.0", | ||
"eslint-plugin-import": "^2.21.2", | ||
"jest": "^26.1.0", | ||
"rollup": "^2.18.0", | ||
"eslint-plugin-import": "^2.22.1", | ||
"jest": "^26.6.0", | ||
"rollup": "^2.32.0", | ||
"rollup-plugin-commonjs": "^10.1.0", | ||
"rollup-plugin-postcss": "^3.1.2", | ||
"rollup-plugin-postcss": "^3.1.8", | ||
"rollup-plugin-vue": "^5.1.9" | ||
} | ||
} |
@@ -96,3 +96,13 @@ # rollup-plugin-bundle-scss | ||
exclusive: Boolean, | ||
// bundlerOptions will be passed into `scss-bundle` package, | ||
// see document here https://github.com/reactway/scss-bundle | ||
bundlerOptions: { | ||
// If tilde import is used, `project` is required for finding `node_modules` | ||
project: String, | ||
dedupeGlobs: String[], | ||
includePaths: String[], | ||
ignoreImports: String[], | ||
}, | ||
}) | ||
``` |
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
9359
103
108
+ Added@types/node@22.9.3(transitive)
+ Addedundici-types@6.19.8(transitive)
- Removed@types/node@22.10.1(transitive)
- Removedundici-types@6.20.0(transitive)