rollup-plugin-sass-bundle
v1.1.2
Published
A simple rollup plugin for transpile sass and bundle and output a single file
Maintainers
Readme
rollup-plugin-sass-bundle
Install
npm install -D rollup-plugin-sass-bundleDescription
A simple rollup plugin that only delegates to the sass runtime used to transpile sass files to css and bundles it all in a single file, optionally bundling can be turned off, in that case the plugin just transforms the files and rollup passes it on to the other plugins.
Usage
// rollup.config.js
import sass from 'rollup-plugin-sass-bundle';
export default {
input: 'index.js',
output: {
file: 'bundle.js',
format: 'esm',
},
plugins: [
sass({
bundleOptions: {
enabled: true,
name: 'bundle.css'
}
})
]
}Config
include and exclude
Type: String | RegExp | Array[...String|RegExp]
Default:
include:['**/*.scss', '**/*.sass']exclude:undefined
A valid picomatch pattern, or array of patterns. If options.include is omitted or has zero length, filter will return true by default. Otherwise, an ID must match one or more of the picomatch patterns, and must not match any of the options.exclude patterns.
Note that picomatch patterns are very similar to minimatch patterns, and in most use cases, they are interchangeable. If you have more specific pattern matching needs, you can view this comparison table to learn more about where the libraries differ.
loadPaths
Type: string[] | undefined
Additional loaded paths passed to the sass compiler
By default only the current directory of the file transformed by rollup and the root directory is passed
runtime
Type: SassCompiler
Default: Would look for and try to import sass
Provide a custom runtime to use instead of the default one.
sourceMap
Type: boolean | undefined
Default: false
Generate source map
sassOptions
Type: SassOptions
Pass or override any sass options, to configure the compilation process.
Importers can be provided here for example resolving node_modules imports using ~ syntax, see nodepackageimporter
Please do not override loadPaths and use the option provided by the plugin, because that would remove the current directory of the processed file and the root directory already provided.
bundleOptions
Type: Object
enabled
Type: boolean | undefined
Default: true
When this option is disabled, the plugin would only compile the sass files and you would be expected to bundle them yourself or pass it to a different plugin.
name and fileName
Type: string | undefined
Default:
name:undefinedfilename:undefined
The name and fileName options would be passed to the rollup emitFile hook.
When emitting chunks or assets, either a name or a fileName can be supplied. If a fileName is provided, it will be used unmodified as the name of the generated file, throwing an error if this causes a conflict. Otherwise, if a name is supplied, this will be used as substitution for [name] in the corresponding output.chunkFileNames or output.assetFileNames pattern, possibly adding a unique number to the end of the file name to avoid conflicts. If neither a name nor fileName is supplied, a default name will be used. Prebuilt chunks must always have a fileName.
include and exclude
Type: String | RegExp | Array[...String|RegExp]
Default:
include:['**/*.scss', '**/*.sass', '**/*.css']exclude:undefined
Same as the base plugin options but these options apply only when bunding, by default this option also includes
A valid picomatch pattern, or array of patterns. If options.include is omitted or has zero length, filter will return true by default. Otherwise, an ID must match one or more of the picomatch patterns, and must not match any of the options.exclude patterns.
Note that picomatch patterns are very similar to minimatch patterns, and in most use cases, they are interchangeable. If you have more specific pattern matching needs, you can view this comparison table to learn more about where the libraries differ.
