rollup-plugin-lib-style 1.0.0 → 1.0.3

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  # rollup-plugin-lib-style
2
2
 
3
- A Rollup plugin that converts CSS files into CSS modules and also imports the generated CSS files.
4
- Under the assumption that your library will be bundled by webpack or another bundler, it gives us the ability to consume only the used styles
3
+ A Rollup plugin that converts CSS and extensions for CSS into CSS modules and imports the generated CSS files.
4
+ Under the assumption the library will be bundled by webpack or another bundler, it gives us the ability to consume only the used styles
5
5
 
6
6
  ## Why
7
7
 
@@ -62,27 +62,27 @@ This gives us the ability to consume only the used style for our component
62
62
 
63
63
  ### classNamePrefix
64
64
 
65
- Type: `string`
66
- Default: ""
65
+ Type: `string`<br />
66
+ Default: ""<br />
67
67
  Description: prefix for the classnames
68
68
 
69
69
  ### scopedName
70
70
 
71
- Type: `string`
72
- Default: "[local]\_[hash:base64:6]"
71
+ Type: `string`<br />
72
+ Default: "[local]\_[hash:base64:6]"<br />
73
73
  Description: customize the scoped name of the classname
74
74
 
75
75
  ### postCssPlugins
76
76
 
77
- Type: object[]
78
- Default: []
77
+ Type: object[]<br />
78
+ Default: []<br />
79
79
  Description: [PostCSS Plugins](https://postcss.org/docs/postcss-plugins)
80
80
 
81
81
  ### loaders
82
82
 
83
- Type: Loader[]
84
- Default: []
85
- Description: loaders for CSS preprocessor languages
83
+ Type: Loader[]<br />
84
+ Default: []<br />
85
+ Description: loaders for CSS preprocessor languages<br />
86
86
  Example:
87
87
 
88
88
  ```js
@@ -99,10 +99,30 @@ export default {
99
99
  ```
100
100
 
101
101
  ### exclude
102
- Type: Array<string | RegExp> | string | RegExp
103
- Default: null
102
+ Type: Array<string | RegExp> | string | RegExp<br />
103
+ Default: null<br />
104
104
  Description: exclude files from load by the loader
105
105
 
106
+
107
+ ## Known Issues
108
+ "Unresolved dependencies" warnings
109
+ ```
110
+ (!) Unresolved dependencies
111
+ https://rollupjs.org/guide/en/#warning-treating-module-as-external-dependency
112
+ @@_MAGIC_PATH_@@/src/components/Component/style.css (imported by "src/components/Component/style.scss")
113
+ ```
114
+
115
+ These warnings can be suppressed by using the "onwarn" function
116
+ ```js
117
+ // rollup.config.js
118
+ import {libStylePlugin, onwarn} from "rollup-plugin-lib-style"
119
+
120
+ export default {
121
+ onwarn,
122
+ plugins: [libStyleLoader()],
123
+ }
124
+ ```
125
+
106
126
  ## License
107
127
 
108
128
  MIT &copy; [Daniel Amenou](https://github.com/DanielAmenou)
package/lib/index.es.js CHANGED
@@ -10,15 +10,15 @@ const defaultScopedName = "[local]_[hash:base64:6]";
10
10
 
11
11
  /**
12
12
  * @typedef {object} postCssLoaderOptions
13
- * @property {object[]} postCssPlugins
14
- * @property {string} classNamePrefix
15
- * @property {string} scopedName
13
+ * @property {object[]} postCssPlugins
14
+ * @property {string} classNamePrefix
15
+ * @property {string} scopedName
16
16
  */
17
17
 
18
18
  /**
19
19
  * @typedef {object} postCssLoaderProps
20
- * @property {postCssLoaderOptions} options
21
- * @property {string} fiePath
20
+ * @property {postCssLoaderOptions} options
21
+ * @property {string} fiePath
22
22
  * @property {string} code
23
23
  */
24
24
 
@@ -93,7 +93,7 @@ const defaultLoaders = [
93
93
 
94
94
  const replaceMagicPath = (fileContent) => fileContent.replace(MAGIC_PATH_REGEX, ".");
95
95
 
96
- const libStylePlugin = (options) => {
96
+ const libStylePlugin = (options = {}) => {
97
97
  const {loaders, include, exclude, ...postCssOptions} = options;
98
98
  const allLoaders = [...(loaders || []), ...defaultLoaders];
99
99
  const filter = createFilter(include, exclude);
@@ -143,12 +143,11 @@ const libStylePlugin = (options) => {
143
143
 
144
144
  const importersPaths = outputPaths
145
145
  .reduce((result, currentPath) => {
146
- result.push(glob.sync(`${path.resolve(process.cwd(), currentPath)}/**/*(${importers.join("|")})`));
146
+ result.push(glob.sync(`${currentPath}/**/*(${importers.join("|")})`));
147
147
  return result
148
148
  }, [])
149
149
  .flat();
150
150
 
151
- //const importersPaths = glob.sync(`lib/**/*(${importers.join("|")})`)
152
151
  await Promise.all(
153
152
  importersPaths.map((currentPath) =>
154
153
  fs
package/lib/index.js CHANGED
@@ -23,15 +23,15 @@ const defaultScopedName = "[local]_[hash:base64:6]";
23
23
 
24
24
  /**
25
25
  * @typedef {object} postCssLoaderOptions
26
- * @property {object[]} postCssPlugins
27
- * @property {string} classNamePrefix
28
- * @property {string} scopedName
26
+ * @property {object[]} postCssPlugins
27
+ * @property {string} classNamePrefix
28
+ * @property {string} scopedName
29
29
  */
30
30
 
31
31
  /**
32
32
  * @typedef {object} postCssLoaderProps
33
- * @property {postCssLoaderOptions} options
34
- * @property {string} fiePath
33
+ * @property {postCssLoaderOptions} options
34
+ * @property {string} fiePath
35
35
  * @property {string} code
36
36
  */
37
37
 
@@ -106,7 +106,7 @@ const defaultLoaders = [
106
106
 
107
107
  const replaceMagicPath = (fileContent) => fileContent.replace(MAGIC_PATH_REGEX, ".");
108
108
 
109
- const libStylePlugin = (options) => {
109
+ const libStylePlugin = (options = {}) => {
110
110
  const {loaders, include, exclude, ...postCssOptions} = options;
111
111
  const allLoaders = [...(loaders || []), ...defaultLoaders];
112
112
  const filter = rollupPluginutils.createFilter(include, exclude);
@@ -156,12 +156,11 @@ const libStylePlugin = (options) => {
156
156
 
157
157
  const importersPaths = outputPaths
158
158
  .reduce((result, currentPath) => {
159
- result.push(glob__default["default"].sync(`${path__default["default"].resolve(process.cwd(), currentPath)}/**/*(${importers.join("|")})`));
159
+ result.push(glob__default["default"].sync(`${currentPath}/**/*(${importers.join("|")})`));
160
160
  return result
161
161
  }, [])
162
162
  .flat();
163
163
 
164
- //const importersPaths = glob.sync(`lib/**/*(${importers.join("|")})`)
165
164
  await Promise.all(
166
165
  importersPaths.map((currentPath) =>
167
166
  fs__default["default"]
package/package.json CHANGED
@@ -1,68 +1,68 @@
1
- {
2
- "name": "rollup-plugin-lib-style",
3
- "version": "1.0.0",
4
- "description": "Rollup plugin that converts CSS and more preprocessor languages into CSS modules and also imports the generated CSS files",
5
- "main": "lib/index.js",
6
- "module": "lib/index.es.js",
7
- "files": [
8
- "lib",
9
- "types/index.d.ts"
10
- ],
11
- "scripts": {
12
- "build": "rollup --input src/index.js --file lib/index.es.js --format es && rollup --input src/index.js --file lib/index.js --format cjs",
13
- "prepublishOnly": "npm run build && npm run test",
14
- "postpublish": "git push && git push --tags",
15
- "publish:beta": "npm version prerelease --preid=beta -m \"beta version - %s\" && npm publish --tag beta",
16
- "publish:patch": "npm version patch -m \"patch version - %s\" && npm publish",
17
- "publish:minor": "npm version minor -m \"minor version - %s\" && npm publish",
18
- "publish:major": "npm version major -m \"major version - %s\" && npm publish",
19
- "lint:fix": "eslint **/*.{js,jsx} --fix",
20
- "lint": "eslint **/*.{js,jsx}",
21
- "test": "jest",
22
- "test:cov": "jest --coverage"
23
- },
24
- "repository": {
25
- "type": "git",
26
- "url": "git+https://github.com/danielamenou/rollup-plugin-lib-style"
27
- },
28
- "keywords": [
29
- "library",
30
- "rollup",
31
- "plugin",
32
- "style",
33
- "sass",
34
- "scss",
35
- "css"
36
- ],
37
- "author": "Daniel Amenou <amenou.daniel@gmail.com>",
38
- "license": "MIT",
39
- "engines": {
40
- "node": ">=16"
41
- },
42
- "types": "./types/index.d.ts",
43
- "devDependencies": {
44
- "@babel/core": "^7.19.3",
45
- "@babel/eslint-parser": "^7.19.1",
46
- "@babel/preset-env": "^7.19.3",
47
- "@types/jest": "^29.1.2",
48
- "babel-core": "^6.26.3",
49
- "babel-jest": "^29.1.2",
50
- "eslint": "^8.25.0",
51
- "eslint-config-prettier": "^8.5.0",
52
- "eslint-config-rem": "^4.0.0",
53
- "eslint-plugin-import": "^2.26.0",
54
- "eslint-plugin-prettier": "^4.2.1",
55
- "eslint-plugin-promise": "^6.0.1",
56
- "fs-extra": "^10.1.0",
57
- "jest": "^29.1.2",
58
- "jest-environment-node-single-context": "^29.0.0",
59
- "prettier": "^2.7.1",
60
- "rollup": "^2.79.1"
61
- },
62
- "dependencies": {
63
- "postcss": "^8.4.17",
64
- "postcss-modules": "^4.0.0",
65
- "rollup-pluginutils": "^2.8.2",
66
- "sass": "^1.55.0"
67
- }
68
- }
1
+ {
2
+ "name": "rollup-plugin-lib-style",
3
+ "version": "1.0.3",
4
+ "description": "A Rollup plugin that converts CSS and extensions for CSS into CSS modules and imports the generated CSS files",
5
+ "main": "lib/index.js",
6
+ "module": "lib/index.es.js",
7
+ "files": [
8
+ "lib",
9
+ "types/index.d.ts"
10
+ ],
11
+ "scripts": {
12
+ "build": "rollup --input src/index.js --file lib/index.es.js --format es && rollup --input src/index.js --file lib/index.js --format cjs",
13
+ "prepublishOnly": "npm run build && npm run test",
14
+ "postpublish": "git push && git push --tags",
15
+ "publish:beta": "npm version prerelease --preid=beta -m \"beta version - %s\" && npm publish --tag beta",
16
+ "publish:patch": "npm version patch -m \"patch version - %s\" && npm publish",
17
+ "publish:minor": "npm version minor -m \"minor version - %s\" && npm publish",
18
+ "publish:major": "npm version major -m \"major version - %s\" && npm publish",
19
+ "lint:fix": "eslint **/*.{js,jsx} --fix",
20
+ "lint": "eslint **/*.{js,jsx}",
21
+ "test": "jest",
22
+ "test:cov": "jest --coverage"
23
+ },
24
+ "repository": {
25
+ "type": "git",
26
+ "url": "git+https://github.com/danielamenou/rollup-plugin-lib-style"
27
+ },
28
+ "keywords": [
29
+ "library",
30
+ "rollup",
31
+ "plugin",
32
+ "style",
33
+ "sass",
34
+ "scss",
35
+ "css"
36
+ ],
37
+ "author": "Daniel Amenou <amenou.daniel@gmail.com>",
38
+ "license": "MIT",
39
+ "engines": {
40
+ "node": ">=16"
41
+ },
42
+ "types": "./types/index.d.ts",
43
+ "devDependencies": {
44
+ "@babel/core": "^7.19.3",
45
+ "@babel/eslint-parser": "^7.19.1",
46
+ "@babel/preset-env": "^7.19.3",
47
+ "@types/jest": "^29.1.2",
48
+ "babel-core": "^6.26.3",
49
+ "babel-jest": "^29.1.2",
50
+ "eslint": "^8.25.0",
51
+ "eslint-config-prettier": "^8.5.0",
52
+ "eslint-config-rem": "^4.0.0",
53
+ "eslint-plugin-import": "^2.26.0",
54
+ "eslint-plugin-prettier": "^4.2.1",
55
+ "eslint-plugin-promise": "^6.0.1",
56
+ "fs-extra": "^10.1.0",
57
+ "jest": "^29.1.2",
58
+ "jest-environment-node-single-context": "^29.0.0",
59
+ "prettier": "^2.7.1",
60
+ "rollup": "^2.79.1"
61
+ },
62
+ "dependencies": {
63
+ "postcss": "^8.4.17",
64
+ "postcss-modules": "^4.0.0",
65
+ "rollup-pluginutils": "^2.8.2",
66
+ "sass": "^1.55.0"
67
+ }
68
+ }