@plumeria/postcss-plugin 4.0.0
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/dist/index.d.ts +1 -0
- package/dist/index.js +30 -0
- package/dist/optimizer.d.ts +1 -0
- package/dist/optimizer.js +26 -0
- package/package.json +36 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const optimizer_1 = require("./optimizer");
|
|
4
|
+
const compiler_1 = require("@plumeria/compiler");
|
|
5
|
+
const plugin = (options = {}) => {
|
|
6
|
+
return {
|
|
7
|
+
postcssPlugin: 'postcss-plumeria',
|
|
8
|
+
async Once(root) {
|
|
9
|
+
const plumeriaAtRules = [];
|
|
10
|
+
root.walkAtRules('plumeria', (atRule) => {
|
|
11
|
+
plumeriaAtRules.push(atRule);
|
|
12
|
+
});
|
|
13
|
+
if (plumeriaAtRules.length === 0) {
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
const { cwd = process.cwd(), exclude = ['**/node_modules/**', '**/dist/**', '**/.next/**'], include = '**/*.{js,jsx,ts,tsx}', } = options;
|
|
17
|
+
const genCSS = (0, compiler_1.compileCSS)({
|
|
18
|
+
include: include,
|
|
19
|
+
exclude: exclude,
|
|
20
|
+
cwd: cwd,
|
|
21
|
+
});
|
|
22
|
+
const optInCSS = await (0, optimizer_1.optimizeCSS)(genCSS);
|
|
23
|
+
plumeriaAtRules.forEach((atRule) => {
|
|
24
|
+
atRule.replaceWith(optInCSS);
|
|
25
|
+
});
|
|
26
|
+
},
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
plugin.postcss = true;
|
|
30
|
+
module.exports = plugin;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function optimizeCSS(cssCode: string): Promise<string>;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.optimizeCSS = optimizeCSS;
|
|
7
|
+
const postcss_1 = __importDefault(require("postcss"));
|
|
8
|
+
const postcss_combine_media_query_1 = __importDefault(require("postcss-combine-media-query"));
|
|
9
|
+
const lightningcss_1 = require("lightningcss");
|
|
10
|
+
async function optimizeCSS(cssCode) {
|
|
11
|
+
const merged = await (0, postcss_1.default)([(0, postcss_combine_media_query_1.default)()]).process(cssCode, {
|
|
12
|
+
from: undefined,
|
|
13
|
+
});
|
|
14
|
+
const light = (0, lightningcss_1.transform)({
|
|
15
|
+
filename: 'stylesheet.css',
|
|
16
|
+
code: Buffer.from(merged.css),
|
|
17
|
+
minify: process.env.NODE_ENV === 'production',
|
|
18
|
+
targets: {
|
|
19
|
+
safari: 16,
|
|
20
|
+
edge: 110,
|
|
21
|
+
firefox: 110,
|
|
22
|
+
chrome: 110,
|
|
23
|
+
},
|
|
24
|
+
});
|
|
25
|
+
return Buffer.from(light.code).toString('utf-8');
|
|
26
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@plumeria/postcss-plugin",
|
|
3
|
+
"version": "4.0.0",
|
|
4
|
+
"description": "Plumeria PostCSS plugin with swc based compiler",
|
|
5
|
+
"author": "Refirst 11",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"funding": "https://github.com/sponsors/refirst11",
|
|
8
|
+
"homepage": "https://plumeria.dev",
|
|
9
|
+
"repository": {
|
|
10
|
+
"type": "git",
|
|
11
|
+
"url": "git+https://github.com/zss-in-js/plumeria.git",
|
|
12
|
+
"directory": "packages/postcss-plugin"
|
|
13
|
+
},
|
|
14
|
+
"bugs": {
|
|
15
|
+
"url": "https://github.com/zss-in-js/plumeria/issues"
|
|
16
|
+
},
|
|
17
|
+
"sideEffects": false,
|
|
18
|
+
"main": "./dist/index.js",
|
|
19
|
+
"types": "./dist/index.d.ts",
|
|
20
|
+
"files": [
|
|
21
|
+
"dist/"
|
|
22
|
+
],
|
|
23
|
+
"scripts": {
|
|
24
|
+
"build": "rimraf dist && pnpm cjs",
|
|
25
|
+
"cjs": "tsc --project tsconfig.cjs.json"
|
|
26
|
+
},
|
|
27
|
+
"dependencies": {
|
|
28
|
+
"@plumeria/compiler": "^4.0.0",
|
|
29
|
+
"lightningcss": "^1.30.2",
|
|
30
|
+
"postcss": "^8.5.6",
|
|
31
|
+
"postcss-combine-media-query": "^2.1.0"
|
|
32
|
+
},
|
|
33
|
+
"publishConfig": {
|
|
34
|
+
"access": "public"
|
|
35
|
+
}
|
|
36
|
+
}
|