@empjs/plugin-postcss 3.0.0-rc.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/README.md ADDED
@@ -0,0 +1,16 @@
1
+ # @empjs/plugin-react
2
+ ## 安装
3
+ ```
4
+ pnpm add @empjs/plugin-postcss -D
5
+ ```
6
+ ## 使用
7
+ ```js
8
+ import pluginPostCss from '@empjs/plugin-postcss'
9
+ import {defineConfig} from '@empjs/cli'
10
+ export default defineConfig(() => {
11
+ return {
12
+ plugins: [pluginPostCss()],
13
+ }
14
+ })
15
+
16
+ ```
@@ -0,0 +1,15 @@
1
+ import type { GlobalStore } from '@empjs/cli';
2
+ export type PluginPostcssType = {
3
+ postcssOptions: any;
4
+ };
5
+ declare const _default: (o: PluginPostcssType) => {
6
+ name: string;
7
+ rsConfig(store: GlobalStore): Promise<void>;
8
+ };
9
+ export default _default;
10
+ declare const postcss: {
11
+ autoprefixer(o?: {}): {}[];
12
+ pxtorem(o?: {}): {}[];
13
+ pxtovw(o?: {}): {}[];
14
+ };
15
+ export { postcss };
package/dist/index.js ADDED
@@ -0,0 +1,28 @@
1
+ import { plugins } from './plugins.js';
2
+ //
3
+ export default (o) => {
4
+ return {
5
+ name: '@empjs/plugin-postcss',
6
+ async rsConfig(store) {
7
+ const { chain, importResolve } = store;
8
+ //
9
+ const ruleMap = ['sass', 'less', 'css'];
10
+ const loaderOptions = {
11
+ postcssOptions: o.postcssOptions,
12
+ };
13
+ for (const ruleName of ruleMap) {
14
+ const rule = chain.module.rule(ruleName);
15
+ const useLightningcss = rule
16
+ .use('postcss')
17
+ .loader(importResolve('postcss-loader', import.meta.url))
18
+ .options(loaderOptions);
19
+ //
20
+ if (['sass', 'less'].includes(ruleName)) {
21
+ useLightningcss.before(`${ruleName}Loader`);
22
+ }
23
+ }
24
+ },
25
+ };
26
+ };
27
+ const postcss = plugins;
28
+ export { postcss };
@@ -0,0 +1,9 @@
1
+ /// <reference types="node" />
2
+ export declare const __filename: string;
3
+ export declare const __dirname: string;
4
+ export declare const require: NodeRequire;
5
+ export declare const plugins: {
6
+ autoprefixer(o?: {}): {}[];
7
+ pxtorem(o?: {}): {}[];
8
+ pxtovw(o?: {}): {}[];
9
+ };
@@ -0,0 +1,48 @@
1
+ import { fileURLToPath } from 'node:url';
2
+ import { dirname } from 'node:path';
3
+ import Module from 'node:module';
4
+ export const __filename = fileURLToPath(import.meta.url);
5
+ export const __dirname = dirname(__filename);
6
+ export const require = Module.createRequire(import.meta.url);
7
+ export const plugins = {
8
+ autoprefixer(o = {}) {
9
+ return [require.resolve('autoprefixer'), o];
10
+ },
11
+ pxtorem(o = {}) {
12
+ o = {
13
+ ...{
14
+ rootValue: 16,
15
+ unitPrecision: 5,
16
+ propList: ['*'],
17
+ selectorBlackList: [],
18
+ replace: true,
19
+ mediaQuery: false,
20
+ minPixelValue: 0,
21
+ },
22
+ ...o,
23
+ };
24
+ return [require.resolve('postcss-pxtorem'), o];
25
+ },
26
+ pxtovw(o = {}) {
27
+ o = {
28
+ ...{
29
+ unitToConvert: 'px',
30
+ viewportWidth: 320,
31
+ viewportHeight: 568, // not now used; TODO: need for different units and math for different properties
32
+ unitPrecision: 5,
33
+ viewportUnit: 'vw',
34
+ fontViewportUnit: 'vw', // vmin is more suitable.
35
+ selectorBlackList: [],
36
+ propList: ['*'],
37
+ minPixelValue: 1,
38
+ mediaQuery: false,
39
+ replace: true,
40
+ landscape: false,
41
+ landscapeUnit: 'vw',
42
+ landscapeWidth: 568,
43
+ },
44
+ ...o,
45
+ };
46
+ return [require.resolve('@empjs/postcss-px-to-viewport'), o];
47
+ },
48
+ };
package/package.json ADDED
@@ -0,0 +1,54 @@
1
+ {
2
+ "name": "@empjs/plugin-postcss",
3
+ "version": "3.0.0-rc.0",
4
+ "description": "emp postcss plugin",
5
+ "license": "MIT",
6
+ "type": "module",
7
+ "files": [
8
+ "dist"
9
+ ],
10
+ "maintainers": [
11
+ "xuhongbin",
12
+ "ckken"
13
+ ],
14
+ "repository": {
15
+ "type": "git",
16
+ "url": "git+https://github.com/empjs/emp.git",
17
+ "directory": "packages/plugin-postcss"
18
+ },
19
+ "publishConfig": {
20
+ "access": "public"
21
+ },
22
+ "keywords": [
23
+ "postcss"
24
+ ],
25
+ "main": "dist/index.js",
26
+ "types": "dist/index.d.ts",
27
+ "exports": {
28
+ ".": "./dist/index.js"
29
+ },
30
+ "scripts": {
31
+ "dev": "rimraf dist && pnpm run /^dev:.*/",
32
+ "dev:tsc": "tsc -w",
33
+ "dev:tsc-alias": "tsc-alias -w",
34
+ "build": "rimraf dist && pnpm run /^build:.*/",
35
+ "build:ts": "tsc && tsc-alias"
36
+ },
37
+ "engines": {
38
+ "node": ">=20.0.0"
39
+ },
40
+ "author": "Ken",
41
+ "devDependencies": {
42
+ "@empjs/cli": "workspace:*",
43
+ "@types/react": "^18.2.30",
44
+ "rimraf": "^5.0.5",
45
+ "tsc-alias": "^1.8.8"
46
+ },
47
+ "dependencies": {
48
+ "postcss": "^8.4.38",
49
+ "postcss-loader": "^8.1.1",
50
+ "autoprefixer": "^10.4.19",
51
+ "@empjs/postcss-px-to-viewport": "^1.0.0",
52
+ "postcss-pxtorem": "^6.1.0"
53
+ }
54
+ }