rollup-plugin-sass-bundle 1.0.0 → 1.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +128 -0
- package/index.js +6 -6
- package/package.json +20 -11
package/README.md
ADDED
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
# rollup-plugin-sass-bundle
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/rollup-plugin-sass-bundle) [](https://www.npmjs.com/package/rollup-plugin-sass) [](https://opensource.org/licenses/MIT)
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```sh
|
|
8
|
+
npm install -D rollup-plugin-sass-bundle
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Description
|
|
12
|
+
|
|
13
|
+
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.
|
|
14
|
+
|
|
15
|
+
## Usage
|
|
16
|
+
|
|
17
|
+
```js
|
|
18
|
+
// rollup.config.js
|
|
19
|
+
import sass from 'rollup-plugin-sass-bundle';
|
|
20
|
+
|
|
21
|
+
export default {
|
|
22
|
+
input: 'index.js',
|
|
23
|
+
output: {
|
|
24
|
+
file: 'bundle.js',
|
|
25
|
+
format: 'esm',
|
|
26
|
+
},
|
|
27
|
+
plugins: [
|
|
28
|
+
sass({
|
|
29
|
+
bundleOptions: {
|
|
30
|
+
enabled: true,
|
|
31
|
+
name: 'bundle.css'
|
|
32
|
+
}
|
|
33
|
+
})
|
|
34
|
+
]
|
|
35
|
+
}
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
## Config
|
|
39
|
+
|
|
40
|
+
### `include` and `exclude`
|
|
41
|
+
|
|
42
|
+
Type: `String | RegExp | Array[...String|RegExp]`<br>
|
|
43
|
+
|
|
44
|
+
Default:
|
|
45
|
+
- `include`: `['**/*.scss', '**/*.sass']`
|
|
46
|
+
- `exclude`: `undefined`
|
|
47
|
+
|
|
48
|
+
A valid [`picomatch`](https://github.com/micromatch/picomatch#globbing-features) 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.
|
|
49
|
+
|
|
50
|
+
Note that `picomatch` patterns are very similar to [`minimatch`](https://github.com/isaacs/minimatch#readme) patterns, and in most use cases, they are interchangeable. If you have more specific pattern matching needs, you can view [this comparison table](https://github.com/micromatch/picomatch#library-comparisons) to learn more about where the libraries differ.
|
|
51
|
+
|
|
52
|
+
### `loadPaths`
|
|
53
|
+
|
|
54
|
+
Type: `string[] | undefined`
|
|
55
|
+
|
|
56
|
+
Additional loaded paths passed to the [`sass compiler`](https://sass-lang.com/documentation/js-api/interfaces/stringoptions/#loadPaths)
|
|
57
|
+
|
|
58
|
+
By default only the current directory of the file transformed by rollup and the root directory is passed
|
|
59
|
+
|
|
60
|
+
### `runtime`
|
|
61
|
+
|
|
62
|
+
Type: [`SassCompiler`](https://sass-lang.com/documentation/js-api/classes/compiler/)
|
|
63
|
+
|
|
64
|
+
`Default`: Would look for and try to import [`sass`]('https://www.npmjs.com/package/sass')
|
|
65
|
+
|
|
66
|
+
Provide a custom runtime to use instead of the default one.
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
### `sourceMap`
|
|
71
|
+
|
|
72
|
+
Type: `boolean | undefined`
|
|
73
|
+
|
|
74
|
+
Default: `false`
|
|
75
|
+
|
|
76
|
+
Generate source map
|
|
77
|
+
|
|
78
|
+
### `sassOptions`
|
|
79
|
+
|
|
80
|
+
Type: [`SassOptions`](https://sass-lang.com/documentation/js-api/interfaces/stringoptions/)
|
|
81
|
+
|
|
82
|
+
Pass or override any sass options, to configure the compilation process.
|
|
83
|
+
|
|
84
|
+
Importers can be provided here for example resolving node_modules imports using `~` syntax, see [nodepackageimporter](https://sass-lang.com/documentation/js-api/classes/nodepackageimporter/)
|
|
85
|
+
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.
|
|
86
|
+
|
|
87
|
+
### `bundleOptions`
|
|
88
|
+
|
|
89
|
+
Type: `Object`
|
|
90
|
+
|
|
91
|
+
#### `enabled`
|
|
92
|
+
|
|
93
|
+
Type: `boolean | undefined`
|
|
94
|
+
|
|
95
|
+
Default: `true`
|
|
96
|
+
|
|
97
|
+
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.
|
|
98
|
+
|
|
99
|
+
#### `name` and `fileName`
|
|
100
|
+
|
|
101
|
+
Type: `string | undefined`
|
|
102
|
+
|
|
103
|
+
Default:
|
|
104
|
+
- `name`: `undefined`
|
|
105
|
+
- `filename`: `undefined`
|
|
106
|
+
|
|
107
|
+
The `name` and `fileName` options would be passed to the rollup [`emitFile`](https://rollupjs.org/plugin-development/#this-emitfile) hook.
|
|
108
|
+
|
|
109
|
+
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.
|
|
110
|
+
|
|
111
|
+
#### `include` and `exclude`
|
|
112
|
+
|
|
113
|
+
Type: `String | RegExp | Array[...String|RegExp]`<br>
|
|
114
|
+
|
|
115
|
+
Default:
|
|
116
|
+
- `include`: `['**/*.scss', '**/*.sass', '**/*.css']`
|
|
117
|
+
- `exclude`: `undefined`
|
|
118
|
+
|
|
119
|
+
Same as the base plugin options but these options apply only when bunding, by default this option also includes
|
|
120
|
+
|
|
121
|
+
A valid [`picomatch`](https://github.com/micromatch/picomatch#globbing-features) 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.
|
|
122
|
+
|
|
123
|
+
Note that `picomatch` patterns are very similar to [`minimatch`](https://github.com/isaacs/minimatch#readme) patterns, and in most use cases, they are interchangeable. If you have more specific pattern matching needs, you can view [this comparison table](https://github.com/micromatch/picomatch#library-comparisons) to learn more about where the libraries differ.
|
|
124
|
+
|
|
125
|
+
|
|
126
|
+
## License
|
|
127
|
+
|
|
128
|
+
[MIT](https://github.com/vrtexe/rollup-plugin-sass-bundle/blob/main/LICENSE)
|
package/index.js
CHANGED
|
@@ -3,9 +3,9 @@ import { dirname } from 'node:path';
|
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* @typedef {Object} SassPluginOptions
|
|
6
|
-
* @property {Parameters<CreateFilter>[1]} [exclude]
|
|
7
6
|
* @property {Parameters<CreateFilter>[0]} [include]
|
|
8
|
-
* @property {
|
|
7
|
+
* @property {Parameters<CreateFilter>[1]} [exclude]
|
|
8
|
+
* @property {string[]} [loadPaths]
|
|
9
9
|
* @property {SassCompiler} [runtime]
|
|
10
10
|
* @property {boolean} [sourceMap]
|
|
11
11
|
* @property {SassOptions} [sassOptions]
|
|
@@ -15,8 +15,8 @@ import { dirname } from 'node:path';
|
|
|
15
15
|
/**
|
|
16
16
|
* @typedef {Object} BundleOptions
|
|
17
17
|
* @property {boolean} [enabled]
|
|
18
|
-
* @property {Parameters<CreateFilter>[1]} [exclude]
|
|
19
18
|
* @property {Parameters<CreateFilter>[0]} [include]
|
|
19
|
+
* @property {Parameters<CreateFilter>[1]} [exclude]
|
|
20
20
|
* @property {string} [name]
|
|
21
21
|
* @property {string} [fileName]
|
|
22
22
|
*/
|
|
@@ -32,7 +32,7 @@ import { dirname } from 'node:path';
|
|
|
32
32
|
* @param {SassPluginOptions} options
|
|
33
33
|
* @returns {import('rollup').Plugin}
|
|
34
34
|
*/
|
|
35
|
-
export default async function
|
|
35
|
+
export default async function(options = {}) {
|
|
36
36
|
/** @type {SassPluginState} */
|
|
37
37
|
const state = {
|
|
38
38
|
bundle: {}
|
|
@@ -66,7 +66,7 @@ export default async function (options = {}) {
|
|
|
66
66
|
}
|
|
67
67
|
|
|
68
68
|
return {
|
|
69
|
-
name: '
|
|
69
|
+
name: 'sass',
|
|
70
70
|
transform(code, id) {
|
|
71
71
|
if (!filter(id)) {
|
|
72
72
|
return bundleFile(code, id);
|
|
@@ -75,7 +75,7 @@ export default async function (options = {}) {
|
|
|
75
75
|
const paths = [dirname(id), process.cwd()];
|
|
76
76
|
|
|
77
77
|
const result = runtime.compileString(code, {
|
|
78
|
-
loadPaths: [...paths, ...(options.
|
|
78
|
+
loadPaths: [...paths, ...(options.loadPaths || [])],
|
|
79
79
|
style: 'compressed',
|
|
80
80
|
sourceMap: options.sourceMap,
|
|
81
81
|
...(options.sassOptions || {})
|
package/package.json
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rollup-plugin-sass-bundle",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.1.1",
|
|
4
4
|
"description": "A simple rollup plugin for transpile sass and bundle and output a single file",
|
|
5
|
+
"license": "MIT",
|
|
5
6
|
"type": "module",
|
|
6
7
|
"main": "index.js",
|
|
7
8
|
"exports": {
|
|
@@ -9,13 +10,6 @@
|
|
|
9
10
|
"default": "./index.js"
|
|
10
11
|
}
|
|
11
12
|
},
|
|
12
|
-
"keywords": [
|
|
13
|
-
"rollup",
|
|
14
|
-
"sass",
|
|
15
|
-
"rollup-plugin",
|
|
16
|
-
"css",
|
|
17
|
-
"scss"
|
|
18
|
-
],
|
|
19
13
|
"author": {
|
|
20
14
|
"name": "Vangel",
|
|
21
15
|
"email": "traykovski5@gmail.com"
|
|
@@ -23,7 +17,6 @@
|
|
|
23
17
|
"files": [
|
|
24
18
|
"index.js"
|
|
25
19
|
],
|
|
26
|
-
"license": "MIT",
|
|
27
20
|
"dependencies": {
|
|
28
21
|
"@rollup/pluginutils": "^5.1.2"
|
|
29
22
|
},
|
|
@@ -31,11 +24,27 @@
|
|
|
31
24
|
"sass": "^1.79.4"
|
|
32
25
|
},
|
|
33
26
|
"peerDependencies": {
|
|
34
|
-
"sass": "
|
|
27
|
+
"sass": ">= 1.45.0"
|
|
35
28
|
},
|
|
36
29
|
"peerDependenciesMeta": {
|
|
37
30
|
"sass": {
|
|
38
31
|
"optional": true
|
|
39
32
|
}
|
|
40
|
-
}
|
|
33
|
+
},
|
|
34
|
+
"homepage": "https://github.com/vrtexe/rollup-plugin-sass-bundle",
|
|
35
|
+
"bugs": {
|
|
36
|
+
"url": "https://github.com/vrtexe/rollup-plugin-sass-bundle/issues",
|
|
37
|
+
"email": "traykovski5@gmail.com"
|
|
38
|
+
},
|
|
39
|
+
"repository": {
|
|
40
|
+
"type": "git",
|
|
41
|
+
"url": "git+https://github.com/vrtexe/rollup-plugin-sass-bundle.git"
|
|
42
|
+
},
|
|
43
|
+
"keywords": [
|
|
44
|
+
"rollup",
|
|
45
|
+
"sass",
|
|
46
|
+
"rollup-plugin",
|
|
47
|
+
"css",
|
|
48
|
+
"scss"
|
|
49
|
+
]
|
|
41
50
|
}
|