rollup-plugin-lib-style 1.2.3 → 1.2.5
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/lib/index.es.js +3 -3
- package/lib/index.js +9 -19
- package/package.json +69 -68
package/lib/index.es.js
CHANGED
|
@@ -52,13 +52,13 @@ const postCssLoader = async ({code, fiePath, options}) => {
|
|
|
52
52
|
const dependencies = [];
|
|
53
53
|
for (const message of result.messages) {
|
|
54
54
|
if (message.type === "dependency") {
|
|
55
|
-
dependencies.
|
|
55
|
+
dependencies.push(message.file);
|
|
56
56
|
}
|
|
57
57
|
}
|
|
58
58
|
|
|
59
59
|
// print postcss warnings
|
|
60
60
|
for (const warning of result.warnings()) {
|
|
61
|
-
console.warn(warning.
|
|
61
|
+
console.warn(`WARNING: ${warning.plugin}:`, warning.text);
|
|
62
62
|
}
|
|
63
63
|
|
|
64
64
|
return {
|
|
@@ -118,7 +118,7 @@ const libStylePlugin = (options = {}) => {
|
|
|
118
118
|
|
|
119
119
|
const postCssResult = await postCssLoader({code: rawCss.code, fiePath: id, options: postCssOptions});
|
|
120
120
|
|
|
121
|
-
for (const
|
|
121
|
+
for (const dependency of postCssResult.dependencies) this.addWatchFile(dependency);
|
|
122
122
|
|
|
123
123
|
const cssFilePath = id.replace(process.cwd(), "").replace(/\\/g, "/");
|
|
124
124
|
|
package/lib/index.js
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
3
|
var rollupPluginutils = require('rollup-pluginutils');
|
|
6
4
|
var postcss = require('postcss');
|
|
7
5
|
var postcssModules = require('postcss-modules');
|
|
@@ -9,14 +7,6 @@ var fs = require('fs-extra');
|
|
|
9
7
|
var sass = require('sass');
|
|
10
8
|
var glob = require('glob');
|
|
11
9
|
|
|
12
|
-
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
13
|
-
|
|
14
|
-
var postcss__default = /*#__PURE__*/_interopDefaultLegacy(postcss);
|
|
15
|
-
var postcssModules__default = /*#__PURE__*/_interopDefaultLegacy(postcssModules);
|
|
16
|
-
var fs__default = /*#__PURE__*/_interopDefaultLegacy(fs);
|
|
17
|
-
var sass__default = /*#__PURE__*/_interopDefaultLegacy(sass);
|
|
18
|
-
var glob__default = /*#__PURE__*/_interopDefaultLegacy(glob);
|
|
19
|
-
|
|
20
10
|
const defaultScopedName = "[local]_[hash:base64:6]";
|
|
21
11
|
|
|
22
12
|
/**
|
|
@@ -46,7 +36,7 @@ const postCssLoader = async ({code, fiePath, options}) => {
|
|
|
46
36
|
const isGlobalStyle = /\.global.(css|scss|sass|less|stylus)$/.test(fiePath);
|
|
47
37
|
|
|
48
38
|
postCssPlugins.unshift(
|
|
49
|
-
|
|
39
|
+
postcssModules({
|
|
50
40
|
generateScopedName: isGlobalStyle ? "[local]" : classNamePrefix + scopedName,
|
|
51
41
|
getJSON: (cssFileName, json) => (modulesExported[cssFileName] = json),
|
|
52
42
|
})
|
|
@@ -58,19 +48,19 @@ const postCssLoader = async ({code, fiePath, options}) => {
|
|
|
58
48
|
map: false,
|
|
59
49
|
};
|
|
60
50
|
|
|
61
|
-
const result = await
|
|
51
|
+
const result = await postcss(postCssPlugins).process(code, postcssOptions);
|
|
62
52
|
|
|
63
53
|
// collect dependencies
|
|
64
54
|
const dependencies = [];
|
|
65
55
|
for (const message of result.messages) {
|
|
66
56
|
if (message.type === "dependency") {
|
|
67
|
-
dependencies.
|
|
57
|
+
dependencies.push(message.file);
|
|
68
58
|
}
|
|
69
59
|
}
|
|
70
60
|
|
|
71
61
|
// print postcss warnings
|
|
72
62
|
for (const warning of result.warnings()) {
|
|
73
|
-
console.warn(warning.
|
|
63
|
+
console.warn(`WARNING: ${warning.plugin}:`, warning.text);
|
|
74
64
|
}
|
|
75
65
|
|
|
76
66
|
return {
|
|
@@ -95,7 +85,7 @@ const defaultLoaders = [
|
|
|
95
85
|
{
|
|
96
86
|
name: "sass",
|
|
97
87
|
regex: /\.(sass|scss)$/,
|
|
98
|
-
process: ({filePath}) => ({code:
|
|
88
|
+
process: ({filePath}) => ({code: sass.compile(filePath).css.toString()}),
|
|
99
89
|
},
|
|
100
90
|
{
|
|
101
91
|
name: "css",
|
|
@@ -130,7 +120,7 @@ const libStylePlugin = (options = {}) => {
|
|
|
130
120
|
|
|
131
121
|
const postCssResult = await postCssLoader({code: rawCss.code, fiePath: id, options: postCssOptions});
|
|
132
122
|
|
|
133
|
-
for (const
|
|
123
|
+
for (const dependency of postCssResult.dependencies) this.addWatchFile(dependency);
|
|
134
124
|
|
|
135
125
|
const cssFilePath = id.replace(process.cwd(), "").replace(/\\/g, "/");
|
|
136
126
|
|
|
@@ -156,7 +146,7 @@ const libStylePlugin = (options = {}) => {
|
|
|
156
146
|
// get all the modules that import CSS files
|
|
157
147
|
const importersPaths = outputPaths
|
|
158
148
|
.reduce((result, currentPath) => {
|
|
159
|
-
result.push(
|
|
149
|
+
result.push(glob.sync(`${currentPath}/**/*.js`));
|
|
160
150
|
return result
|
|
161
151
|
}, [])
|
|
162
152
|
.flat();
|
|
@@ -164,11 +154,11 @@ const libStylePlugin = (options = {}) => {
|
|
|
164
154
|
// replace magic path with relative path
|
|
165
155
|
await Promise.all(
|
|
166
156
|
importersPaths.map((currentPath) =>
|
|
167
|
-
|
|
157
|
+
fs
|
|
168
158
|
.readFile(currentPath)
|
|
169
159
|
.then((buffer) => buffer.toString())
|
|
170
160
|
.then(replaceMagicPath)
|
|
171
|
-
.then((fileContent) =>
|
|
161
|
+
.then((fileContent) => fs.writeFile(currentPath, fileContent))
|
|
172
162
|
)
|
|
173
163
|
);
|
|
174
164
|
},
|
package/package.json
CHANGED
|
@@ -1,68 +1,69 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "rollup-plugin-lib-style",
|
|
3
|
-
"version": "1.2.
|
|
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
|
-
"
|
|
15
|
-
"
|
|
16
|
-
"publish:
|
|
17
|
-
"publish:
|
|
18
|
-
"publish:
|
|
19
|
-
"
|
|
20
|
-
"lint": "eslint **/*.{js,jsx}",
|
|
21
|
-
"
|
|
22
|
-
"test
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
"
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
"
|
|
31
|
-
"
|
|
32
|
-
"
|
|
33
|
-
"
|
|
34
|
-
"
|
|
35
|
-
"
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
"
|
|
39
|
-
"
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
"
|
|
44
|
-
|
|
45
|
-
"@babel/
|
|
46
|
-
"@babel/
|
|
47
|
-
"@
|
|
48
|
-
"
|
|
49
|
-
"babel-
|
|
50
|
-
"
|
|
51
|
-
"eslint
|
|
52
|
-
"eslint-config-
|
|
53
|
-
"eslint-
|
|
54
|
-
"eslint-plugin-
|
|
55
|
-
"eslint-plugin-
|
|
56
|
-
"
|
|
57
|
-
"
|
|
58
|
-
"jest
|
|
59
|
-
"
|
|
60
|
-
"
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
"postcss
|
|
65
|
-
"
|
|
66
|
-
"
|
|
67
|
-
|
|
68
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "rollup-plugin-lib-style",
|
|
3
|
+
"version": "1.2.5",
|
|
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
|
+
"prepack": "npm run build",
|
|
15
|
+
"postpublish": "git push && git push --tags",
|
|
16
|
+
"publish:beta": "npm version prerelease --preid=beta -m \"beta version - %s\" && npm publish --tag beta",
|
|
17
|
+
"publish:patch": "npm version patch -m \"patch version - %s\" && npm publish",
|
|
18
|
+
"publish:minor": "npm version minor -m \"minor version - %s\" && npm publish",
|
|
19
|
+
"publish:major": "npm version major -m \"major version - %s\" && npm publish",
|
|
20
|
+
"lint:fix": "eslint **/*.{js,jsx} --fix",
|
|
21
|
+
"lint": "eslint **/*.{js,jsx}",
|
|
22
|
+
"test": "jest",
|
|
23
|
+
"test:cov": "jest --coverage"
|
|
24
|
+
},
|
|
25
|
+
"repository": {
|
|
26
|
+
"type": "git",
|
|
27
|
+
"url": "git+https://github.com/danielamenou/rollup-plugin-lib-style"
|
|
28
|
+
},
|
|
29
|
+
"keywords": [
|
|
30
|
+
"library",
|
|
31
|
+
"rollup",
|
|
32
|
+
"plugin",
|
|
33
|
+
"style",
|
|
34
|
+
"sass",
|
|
35
|
+
"scss",
|
|
36
|
+
"css"
|
|
37
|
+
],
|
|
38
|
+
"author": "Daniel Amenou <amenou.daniel@gmail.com>",
|
|
39
|
+
"license": "MIT",
|
|
40
|
+
"engines": {
|
|
41
|
+
"node": ">=16"
|
|
42
|
+
},
|
|
43
|
+
"types": "./types/index.d.ts",
|
|
44
|
+
"devDependencies": {
|
|
45
|
+
"@babel/core": "^7.20.5",
|
|
46
|
+
"@babel/eslint-parser": "^7.19.1",
|
|
47
|
+
"@babel/preset-env": "^7.20.2",
|
|
48
|
+
"@types/jest": "^29.2.3",
|
|
49
|
+
"babel-core": "^6.26.3",
|
|
50
|
+
"babel-jest": "^29.3.1",
|
|
51
|
+
"eslint": "^8.28.0",
|
|
52
|
+
"eslint-config-prettier": "^8.5.0",
|
|
53
|
+
"eslint-config-rem": "^4.0.0",
|
|
54
|
+
"eslint-plugin-import": "^2.26.0",
|
|
55
|
+
"eslint-plugin-prettier": "^4.2.1",
|
|
56
|
+
"eslint-plugin-promise": "^6.1.1",
|
|
57
|
+
"fs-extra": "^11.0.0",
|
|
58
|
+
"jest": "^29.3.1",
|
|
59
|
+
"jest-environment-node-single-context": "^29.0.0",
|
|
60
|
+
"prettier": "^2.8.0",
|
|
61
|
+
"rollup": "^3.5.0"
|
|
62
|
+
},
|
|
63
|
+
"dependencies": {
|
|
64
|
+
"postcss": "^8.4.19",
|
|
65
|
+
"postcss-modules": "^6.0.0",
|
|
66
|
+
"rollup-pluginutils": "^2.8.2",
|
|
67
|
+
"sass": "^1.56.1"
|
|
68
|
+
}
|
|
69
|
+
}
|