@tarojs/rn-style-transformer 3.5.0-alpha.15 → 3.5.0-alpha.16
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/__tests__/index.spec.js +14 -0
- package/dist/index.js +15 -1
- package/dist/index.js.map +1 -1
- package/dist/transforms/index.js +22 -28
- package/dist/transforms/index.js.map +1 -1
- package/dist/transforms/less.js +2 -2
- package/dist/transforms/less.js.map +1 -1
- package/dist/transforms/postcss.js +5 -5
- package/dist/transforms/postcss.js.map +1 -1
- package/dist/transforms/sass.js.map +1 -1
- package/dist/transforms/stylus.js.map +1 -1
- package/dist/utils/index.js +5 -5
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/lessImport.js.map +1 -1
- package/package.json +17 -22
- package/src/index.ts +15 -0
- package/src/transforms/index.ts +17 -23
- package/src/transforms/less.ts +32 -31
- package/src/transforms/postcss.ts +10 -9
- package/src/transforms/sass.ts +6 -5
- package/src/transforms/stylus.ts +17 -16
- package/src/utils/index.ts +3 -2
- package/src/utils/lessImport.ts +1 -0
package/__tests__/index.spec.js
CHANGED
|
@@ -41,6 +41,20 @@ describe('style transform', () => {
|
|
|
41
41
|
}`))
|
|
42
42
|
})
|
|
43
43
|
|
|
44
|
+
it('.css transform viewport unit', async () => {
|
|
45
|
+
const css = await run(`
|
|
46
|
+
.test {
|
|
47
|
+
height: 10vh;
|
|
48
|
+
}
|
|
49
|
+
`)
|
|
50
|
+
expect(css).toEqual(getWrapedCSS(`{
|
|
51
|
+
"test": {
|
|
52
|
+
"height": scaleVu2dp(10, 'vh')
|
|
53
|
+
},
|
|
54
|
+
"__viewportUnits": true
|
|
55
|
+
}`))
|
|
56
|
+
})
|
|
57
|
+
|
|
44
58
|
it('.css transform @import', async () => {
|
|
45
59
|
const css = await run(`
|
|
46
60
|
@import './b.css';
|
package/dist/index.js
CHANGED
|
@@ -26,7 +26,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
26
26
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
27
|
};
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
exports.transform = void 0;
|
|
29
|
+
exports.rollupTransform = exports.transform = void 0;
|
|
30
30
|
const path = __importStar(require("path"));
|
|
31
31
|
// import semver from 'semver'
|
|
32
32
|
// import reactNativePKG from 'react-native/package.json'
|
|
@@ -65,4 +65,18 @@ async function transform(src, filename, options) {
|
|
|
65
65
|
return upstreamTransformer.transform({ src, filename, options });
|
|
66
66
|
}
|
|
67
67
|
exports.transform = transform;
|
|
68
|
+
function rollupTransform(options) {
|
|
69
|
+
return {
|
|
70
|
+
name: 'rn-style-transformer',
|
|
71
|
+
async transform(src, filename) {
|
|
72
|
+
const ext = path.extname(filename);
|
|
73
|
+
if (RN_CSS_EXT.includes(ext)) {
|
|
74
|
+
const styleTransform = getSingleStyleTransform(options.config);
|
|
75
|
+
const code = await styleTransform.transform(src, filename, options);
|
|
76
|
+
return { code };
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
exports.rollupTransform = rollupTransform;
|
|
68
82
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,2CAA4B;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,2CAA4B;AAE5B,8BAA8B;AAC9B,yDAAyD;AACzD,8DAAyC;AAEzC,MAAM,UAAU,GAAG,CAAC,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,SAAS,CAAC,CAAA;AAE1E,0BAA0B;AAC1B,0DAA0D;AAC1D,yEAAyE;AAEzE,M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Q,CAAC,CAAA;YAClC,IAAI,UAAU,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE;gBAC5B,MAAM,cAAc,GAAG,uBAAuB,CAAE,OAAe,CAAC,MAAM,CAAC,CAAA;gBACvE,MAAM,IAAI,GAAG,MAAM,cAAc,CAAC,SAAS,CAAC,GAAG,EAAE,QAAQ,EAAE,OAAO,CAAC,CAAA;gBACnE,OAAO,EAAE,IAAI,EAAE,CAAA;aAChB;QACH,CAAC;KACF,CAAA;AACH,CAAC;AAZD,0CAYC"}
|
package/dist/transforms/index.js
CHANGED
|
@@ -27,26 +27,19 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
27
27
|
};
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
29
|
exports.getWrapedCSS = void 0;
|
|
30
|
+
const helper_1 = require("@tarojs/helper");
|
|
30
31
|
const path = __importStar(require("path"));
|
|
31
32
|
const taro_css_to_react_native_1 = __importDefault(require("taro-css-to-react-native"));
|
|
32
|
-
const
|
|
33
|
+
const utils_1 = require("../utils");
|
|
34
|
+
const less_1 = __importDefault(require("./less"));
|
|
33
35
|
const postcss_1 = __importStar(require("./postcss"));
|
|
34
36
|
const sass_1 = __importDefault(require("./sass"));
|
|
35
|
-
const less_1 = __importDefault(require("./less"));
|
|
36
|
-
const stylus_1 = __importStar(require("./stylus"));
|
|
37
37
|
const StyleSheet_1 = require("./StyleSheet");
|
|
38
|
-
const
|
|
38
|
+
const stylus_1 = __importStar(require("./stylus"));
|
|
39
39
|
function getWrapedCSS(css) {
|
|
40
40
|
return `
|
|
41
|
-
import { StyleSheet
|
|
42
|
-
|
|
43
|
-
// 一般app 只有竖屏模式,所以可以只获取一次 width
|
|
44
|
-
const deviceWidthDp = Dimensions.get('window').width
|
|
45
|
-
const uiWidthPx = 375
|
|
46
|
-
|
|
47
|
-
function scalePx2dp (uiElementPx) {
|
|
48
|
-
return uiElementPx * deviceWidthDp / uiWidthPx
|
|
49
|
-
}
|
|
41
|
+
import { StyleSheet } from 'react-native'
|
|
42
|
+
import { scalePx2dp, scaleVu2dp } from '@tarojs/runtime-rn'
|
|
50
43
|
|
|
51
44
|
// 用来标识 rn-runner transformer 是否读写缓存
|
|
52
45
|
function ignoreStyleFileCache() {}
|
|
@@ -67,7 +60,7 @@ function validateStyle({ styleObject, filename }) {
|
|
|
67
60
|
// 先忽略掉 scalePx2dp 的报错
|
|
68
61
|
if (/Invalid prop `.*` of type `string` supplied to `.*`, expected `number`[^]*/g.test(err.message))
|
|
69
62
|
return;
|
|
70
|
-
(0, helper_1.printLog)("warning" /* WARNING */, err.message, `entry file: ${filename}`);
|
|
63
|
+
(0, helper_1.printLog)("warning" /* processTypeEnum.WARNING */, err.message, `entry file: ${filename}`);
|
|
71
64
|
}
|
|
72
65
|
}
|
|
73
66
|
}
|
|
@@ -78,17 +71,17 @@ const deviceRatio = {
|
|
|
78
71
|
828: 1.81 / 2
|
|
79
72
|
};
|
|
80
73
|
const DEFAULT_RN_CONFIG = {
|
|
81
|
-
["postcss" /* POSTCSS */]: {
|
|
74
|
+
["postcss" /* ProcessTypes.POSTCSS */]: {
|
|
82
75
|
options: {},
|
|
83
76
|
scalable: true
|
|
84
77
|
},
|
|
85
|
-
["sass" /* SASS */]: {
|
|
78
|
+
["sass" /* ProcessTypes.SASS */]: {
|
|
86
79
|
options: {}
|
|
87
80
|
},
|
|
88
|
-
["less" /* LESS */]: {
|
|
81
|
+
["less" /* ProcessTypes.LESS */]: {
|
|
89
82
|
options: {}
|
|
90
83
|
},
|
|
91
|
-
["stylus" /* STYLUS */]: {
|
|
84
|
+
["stylus" /* ProcessTypes.STYLUS */]: {
|
|
92
85
|
options: stylus_1.defaultOptions
|
|
93
86
|
}
|
|
94
87
|
};
|
|
@@ -107,13 +100,13 @@ class StyleTransform {
|
|
|
107
100
|
Reflect.ownKeys(this.config.rn).forEach((key) => {
|
|
108
101
|
var _a;
|
|
109
102
|
if ([
|
|
110
|
-
"sass" /* SASS */,
|
|
111
|
-
"less" /* LESS */,
|
|
112
|
-
"stylus" /* STYLUS */,
|
|
113
|
-
"postcss" /* POSTCSS */
|
|
103
|
+
"sass" /* ProcessTypes.SASS */,
|
|
104
|
+
"less" /* ProcessTypes.LESS */,
|
|
105
|
+
"stylus" /* ProcessTypes.STYLUS */,
|
|
106
|
+
"postcss" /* ProcessTypes.POSTCSS */
|
|
114
107
|
].includes(key.toLocaleLowerCase())) {
|
|
115
108
|
const processConfig = Object.assign(Object.assign({}, this.config.rn[key]), { alias: (_a = config.alias) !== null && _a !== void 0 ? _a : {} });
|
|
116
|
-
if (key.toLocaleLowerCase() === "sass" /* SASS */) {
|
|
109
|
+
if (key.toLocaleLowerCase() === "sass" /* ProcessTypes.SASS */) {
|
|
117
110
|
processConfig.sass = this.config.sass;
|
|
118
111
|
}
|
|
119
112
|
this.processConfigMap.set(key, processConfig);
|
|
@@ -135,13 +128,13 @@ class StyleTransform {
|
|
|
135
128
|
let additionalData = '';
|
|
136
129
|
const ext = path.extname(filename);
|
|
137
130
|
if (/.less$/i.test(ext)) {
|
|
138
|
-
result = await (0, less_1.default)(src, filename, this.processConfigMap.get("less" /* LESS */));
|
|
131
|
+
result = await (0, less_1.default)(src, filename, this.processConfigMap.get("less" /* ProcessTypes.LESS */));
|
|
139
132
|
}
|
|
140
133
|
else if (/.s(c|a)ss$/i.test(ext)) {
|
|
141
|
-
result = await (0, sass_1.default)(src, filename, this.processConfigMap.get("sass" /* SASS */), options);
|
|
134
|
+
result = await (0, sass_1.default)(src, filename, this.processConfigMap.get("sass" /* ProcessTypes.SASS */), options);
|
|
142
135
|
}
|
|
143
136
|
else if (/.styl(us)?$/i.test(ext)) {
|
|
144
|
-
result = await (0, stylus_1.default)(src, filename, this.processConfigMap.get("stylus" /* STYLUS */));
|
|
137
|
+
result = await (0, stylus_1.default)(src, filename, this.processConfigMap.get("stylus" /* ProcessTypes.STYLUS */));
|
|
145
138
|
}
|
|
146
139
|
if (result) {
|
|
147
140
|
css = Buffer.isBuffer(result.css) ? result.css.toString() : result.css;
|
|
@@ -155,7 +148,7 @@ class StyleTransform {
|
|
|
155
148
|
filename,
|
|
156
149
|
additionalData,
|
|
157
150
|
transformOptions: options,
|
|
158
|
-
postcssConfig: this.processConfigMap.get("postcss" /* POSTCSS */)
|
|
151
|
+
postcssConfig: this.processConfigMap.get("postcss" /* ProcessTypes.POSTCSS */)
|
|
159
152
|
});
|
|
160
153
|
}
|
|
161
154
|
/**
|
|
@@ -202,7 +195,8 @@ class StyleTransform {
|
|
|
202
195
|
// stylelint,转换成对象,对对象进行校验
|
|
203
196
|
validateStyle({ styleObject, filename });
|
|
204
197
|
const css = JSON.stringify(styleObject, null, 2)
|
|
205
|
-
.replace(/"(scalePx2dp\(.*?\))"/g, '$1')
|
|
198
|
+
.replace(/"(scalePx2dp\(.*?\))"/g, '$1')
|
|
199
|
+
.replace(/"(scaleVu2dp\(.*?\))"/g, '$1');
|
|
206
200
|
// 注入自适应方法 scalePx2dp
|
|
207
201
|
return getWrapedCSS(css);
|
|
208
202
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/transforms/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,2CAA4B;AAC5B,wFAAmD;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/transforms/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,2CAA0E;AAC1E,2CAA4B;AAC5B,wFAAmD;AAGnD,oCAA6C;AAC7C,kDAA4D;AAC5D,qDAAyF;AACzF,kDAA8E;AAC9E,6CAAmD;AACnD,mDAA0G;AAE1G,SAAgB,YAAY,CAAE,GAAG;IAC/B,OAAO;;;;;;;mCAO0B,GAAG;CACrC,CAAA;AACD,CAAC;AAVD,oCAUC;AAED;;GAEG;AACH,SAAS,aAAa,CAAE,EAAE,WAAW,EAAE,QAAQ,EAAE;IAC/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,GAAG,EACH,QAAQ,EACR;YACE,OAAO;YACP,OAAO,kCACF,aAAa,CAAC,OAAO,KACxB,GAAG,EAAE,GAAG,IAAI;oBACV,IAAI,EAAE,IAAA,0BAAkB,EAAC,GAAG,EAAE,QAAQ,CAAC;oBACvC,MAAM,EAAE,KAAK;oBACb,UAAU,EAAE,KAAK;iBAClB,GACF;SACF,CACF,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE;YACd,uCACK,MAAM,KACT,QAAQ,IACT;QACH,CAAC,CAAC,CAAA;IACJ,CAAC;IAED;;;;;;OAMG;IACH,KAAK,CAAC,SAAS,CAAE,GAAW,EAAE,QAAgB,EAAE,UAAU,EAAsB;;QAC9E,wDAAwD;QACxD,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,YAAY,CAAC,GAAG,EAAE,QAAQ,EAAE,OAAO,CAAC,CAAA;QAE9D,4DAA4D;QAC5D,MAAM,WAAW,GAAG,IAAA,kCAAY,EAC9B,MAAM,CAAC,GAAG,EACV;YACE,iBAAiB,EAAE,IAAI;YACvB,QAAQ,EAAE,MAAA,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,OAAO,0CAAE,QAAQ;SAC3C,CACF,CAAA;QAED,0BAA0B;QAC1B,aAAa,CAAC,EAAE,WAAW,EAAE,QAAQ,EAAE,CAAC,CAAA;QACxC,MAAM,GAAG,GAAG,IAAI,CAAC,SAAS,CAAC,WAAW,EAAE,IAAI,EAAE,CAAC,CAAC;aAC7C,OAAO,CAAC,wBAAwB,EAAE,IAAI,CAAC;aACvC,OAAO,CAAC,wBAAwB,EAAE,IAAI,CAAC,CAAA;QAE1C,qBAAqB;QACrB,OAAO,YAAY,CAAC,GAAG,CAAC,CAAA;IAC1B,CAAC;CACF;AArJD,iCAqJC"}
|
package/dist/transforms/less.js
CHANGED
|
@@ -26,10 +26,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
26
26
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
27
|
};
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
const path = __importStar(require("path"));
|
|
30
29
|
const less_1 = __importDefault(require("less"));
|
|
31
|
-
const
|
|
30
|
+
const path = __importStar(require("path"));
|
|
32
31
|
const utils_1 = require("../utils");
|
|
32
|
+
const lessImport_1 = __importDefault(require("../utils/lessImport"));
|
|
33
33
|
function renderToCSS(src, filename, options = {}) {
|
|
34
34
|
// default plugins
|
|
35
35
|
const plugins = [(0, lessImport_1.default)(options)];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"less.js","sourceRoot":"","sources":["../../src/transforms/less.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,
|
|
1
|
+
{"version":3,"file":"less.js","sourceRoot":"","sources":["../../src/transforms/less.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,gDAAuB;AACvB,2CAA4B;AAG5B,oCAA0D;AAC1D,qEAAgD;AA6DhD,SAAS,WAAW,CAAE,GAAG,EAAE,QAAQ,EAAE,UAAU,EAAS;IACtD,kBAAkB;IAClB,MAAM,OAAO,GAAG,CAAC,IAAA,oBAAc,EAAC,OAAO,CAAC,CAAC,CAAA;IACzC,qCAAqC;IACrC,MAAM,KAAK,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAA;IACnE,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACrC,cAAI;aACD,MAAM,CAAC,GAAG,kCACN,OAAO,KACV,QAAQ,EACR,OAAO,EAAE,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC,OAAO,IAAI,EAAE,CAAC,EAC9C,KAAK,EAAE,KAAK,CAAC,MAAM,CAAC,OAAO,CAAC,KAAK,IAAI,EAAE,CAAC,KACvC,CAAC,GAAG,EAAE,MAAM,EAAE,EAAE;YACjB,IAAI,GAAG,EAAE;gBACP,OAAO,MAAM,CAAC,GAAG,CAAC,OAAO,CAAC,CAAA;aAC3B;YACD,OAAO,CAAC,MAAM,CAAC,CAAA;QACjB,CAAC,CAAC,CAAA;IACN,CAAC,CAAC,CAAA;AACJ,CAAC;AAED,SAAwB,SAAS,CAC/B,GAAW,EACX,QAAgB,EAChB,MAAc;IAEd,MAAM,cAAc,GAAG,IAAA,yBAAiB,EAAC,GAAG,EAAE,MAAM,CAAC,cAAc,CAAC,CAAA;IACpE,MAAM,IAAI,GAAG,IAAA,oBAAY,EAAC,GAAG,EAAE,cAAc,CAAC,CAAA;IAE9C,OAAO,WAAW,CAChB,IAAI,EACJ,QAAQ,kBAEN,SAAS,EAAE;YACT,cAAc,EAAE,GAAG,QAAQ,MAAM;SAClC,EACD,KAAK,EAAE,MAAM,CAAC,KAAK,IAChB,MAAM,CAAC,OAAO,EAEpB,CAAC,IAAI,CAAC,CAAC,MAAoB,EAAE,EAAE;QAC9B,OAAO,gCAAK,MAAM,KAAE,cAAc,GAA4B,CAAA;IAChE,CAAC,CAAC,CAAA;AACJ,CAAC;AArBD,4BAqBC"}
|
|
@@ -27,15 +27,15 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
27
27
|
};
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
29
|
exports.makePostcssPlugins = void 0;
|
|
30
|
+
const helper_1 = require("@tarojs/helper");
|
|
30
31
|
const path = __importStar(require("path"));
|
|
31
|
-
const resolve_1 = require("resolve");
|
|
32
32
|
const postcss_1 = __importDefault(require("postcss"));
|
|
33
|
-
const postcss_pxtransform_1 = __importDefault(require("postcss-pxtransform"));
|
|
34
33
|
const postcss_import_1 = __importDefault(require("postcss-import"));
|
|
35
|
-
const
|
|
34
|
+
const postcss_pxtransform_1 = __importDefault(require("postcss-pxtransform"));
|
|
35
|
+
const resolve_1 = require("resolve");
|
|
36
|
+
const rn_stylelint_json_1 = __importDefault(require("../config/rn-stylelint.json"));
|
|
36
37
|
const utils_1 = require("../utils");
|
|
37
38
|
const reporterSkip_1 = __importDefault(require("../utils/reporterSkip"));
|
|
38
|
-
const rn_stylelint_json_1 = __importDefault(require("../config/rn-stylelint.json"));
|
|
39
39
|
const defaultPxtransformOption = {
|
|
40
40
|
enable: true,
|
|
41
41
|
config: {
|
|
@@ -77,7 +77,7 @@ function makePostcssPlugins({ filename, designWidth, deviceRatio, postcssConfig,
|
|
|
77
77
|
}
|
|
78
78
|
catch (e) {
|
|
79
79
|
const msg = e.code === 'MODULE_NOT_FOUND' ? `缺少postcss插件${pluginName}, 已忽略` : e;
|
|
80
|
-
(0, helper_1.printLog)(msg, "warning" /* WARNING */);
|
|
80
|
+
(0, helper_1.printLog)(msg, "warning" /* processTypeEnum.WARNING */);
|
|
81
81
|
}
|
|
82
82
|
});
|
|
83
83
|
return plugins;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"postcss.js","sourceRoot":"","sources":["../../src/transforms/postcss.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,2CAA4B;AAC5B,
|
|
1
|
+
{"version":3,"file":"postcss.js","sourceRoot":"","sources":["../../src/transforms/postcss.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,2CAAoF;AACpF,2CAA4B;AAC5B,sDAAiD;AACjD,oEAA0C;AAC1C,8EAA6C;AAC7C,qCAA6C;AAE7C,oFAAyD;AACzD,oCAAuC;AACvC,yEAAgD;AAWhD,MAAM,wBAAwB,GAE1B;IACF,MAAM,EAAE,IAAI;IACZ,MAAM,EAAE;QACN,QAAQ,EAAE,IAAI;KACf;CACF,CAAA;AAED,SAAgB,kBAAkB,CAAE,EAClC,QAAQ,EACR,WAAW,EACX,WAAW,EACX,aAAa,EACb,gBAAgB,EAChB,cAAc,EACf;IACC,MAAM,mBAAmB,GAAG,CAAC,aAAa,EAAE,gBAAgB,E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AM,CAAC,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC,CAAA;QAExC,KAAK,MAAM,OAAO,IAAI,WAAW,EAAE;YACjC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,EAAE,OAAO,CAAC,CAAA;SACjC;KACF;IAED,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACrC,IAAI,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE;YACvB,IAAI,GAAG,EAAE;gBACP,MAAM,CAAC,GAAG,CAAC,CAAA;aACZ;iBAAM;gBACL,OAAO,CAAC;oBACN,GAAG;oBACH,GAAG,EAAE,IAAI,CAAC,SAAS;iBACpB,CAAC,CAAA;aACH;QACH,CAAC,CAAC,CAAA;IACJ,CAAC,CAAC,CAAA;AACJ,CAAC;AAED,SAAwB,SAAS,CAAE,GAAW,EAAE,QAAgB,EAAE,MAAc;IAC9E,MAAM,cAAc,GAAG,IAAA,yBAAiB,EAAC,GAAG,EAAE,MAAM,CAAC,cAAc,CAAC,CAAA;IACpE,MAAM,IAAI,GAAG,IAAA,oBAAY,EAAC,GAAG,EAAE,cAAc,CAAC,CAAA;IAE9C,OAAO,WAAW,CAChB,IAAI,EACJ,QAAQ,EACR,MAAM,CAAC,OAAO,CACf,CAAC,IAAI,CAAC,CAAC,MAAoB,EAAE,EAAE;QAC9B,OAAO,gCAAK,MAAM,KAAE,cAAc,GAA4B,CAAA;IAChE,CAAC,CAAC,CAAA;AACJ,CAAC;AAXD,4BAWC"}
|
package/dist/utils/index.js
CHANGED
|
@@ -27,9 +27,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
27
27
|
};
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
29
|
exports.getAdditionalData = exports.normalizeSourceMap = exports.normalizePath = exports.resolveStyle = exports.findVariant = exports.insertAfter = exports.insertBefore = void 0;
|
|
30
|
+
const helper_1 = require("@tarojs/helper");
|
|
30
31
|
const fs = __importStar(require("fs"));
|
|
31
32
|
const path = __importStar(require("path"));
|
|
32
|
-
const helper_1 = require("@tarojs/helper");
|
|
33
33
|
const resolve = __importStar(require("resolve"));
|
|
34
34
|
const node_modules_paths_1 = __importDefault(require("resolve/lib/node-modules-paths"));
|
|
35
35
|
function insertBefore(source, additional) {
|
|
@@ -80,7 +80,7 @@ exports.findVariant = findVariant;
|
|
|
80
80
|
* @param opts { basedir, platform, paths }
|
|
81
81
|
*/
|
|
82
82
|
function resolveStyle(id, opts) {
|
|
83
|
-
const { basedir, platform, paths = [], alias = {}, defaultExt = '', logLevel = "error" /* ERROR */ } = opts;
|
|
83
|
+
const { basedir, platform, paths = [], alias = {}, defaultExt = '', logLevel = "error" /* LogLevelEnum.ERROR */ } = opts;
|
|
84
84
|
id = id.trim();
|
|
85
85
|
Object.keys(alias).forEach(key => {
|
|
86
86
|
if (id.startsWith(key)) {
|
|
@@ -122,11 +122,11 @@ function resolveStyle(id, opts) {
|
|
|
122
122
|
${includePaths.join(',\n ')}
|
|
123
123
|
]
|
|
124
124
|
`;
|
|
125
|
-
if (logLevel === "error" /* ERROR */) {
|
|
125
|
+
if (logLevel === "error" /* LogLevelEnum.ERROR */) {
|
|
126
126
|
throw new Error(levelMessage);
|
|
127
127
|
}
|
|
128
|
-
if (logLevel === "warning" /* WARNING */) {
|
|
129
|
-
(0, helper_1.printLog)("warning" /* WARNING */, levelMessage);
|
|
128
|
+
if (logLevel === "warning" /* LogLevelEnum.WARNING */) {
|
|
129
|
+
(0, helper_1.printLog)("warning" /* processTypeEnum.WARNING */, levelMessage);
|
|
130
130
|
return id;
|
|
131
131
|
}
|
|
132
132
|
}
|
package/dist/utils/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,uCAAwB;AACxB,2CAA4B;AA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ClB,UAAU,KAAK,eAAe,IAAI,UAAU;oBAC1C,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,UAAU,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;oBACjD,CAAC,CAAC,aAAa,CAAC,MAAM,CAAC,CAAA;gBAE3B,OAAO,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,EAAE,cAAc,CAAC,CAAA;aACjE;YAED,OAAO,MAAM,CAAA;QACf,CAAC,CAAC,CAAA;KACH;IAED,OAAO,MAAM,CAAA;AACf,CAAC;AAzCD,gDAyCC;AACD,WAAW;AAEX,SAAgB,iBAAiB,CAAE,IAAY,EAAE,MAA2C;IAC1F,IAAI,cAAc,GAAG,EAAE,CAAA;IACvB,IAAI,OAAO,MAAM,KAAK,WAAW,EAAE;QACjC,cAAc;YACZ,OAAO,MAAM,KAAK,UAAU;gBAC1B,CAAC,CAAC,GAAG,MAAM,CAAC,IAAI,CAAC,EAAE;gBACnB,CAAC,CAAC,MAAM,CAAA;KACb;IACD,OAAO,cAAc,CAAA;AACvB,CAAC;AATD,8CASC;AAED,kBAAe,EAAE,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lessImport.js","sourceRoot":"","sources":["../../src/utils/lessImport.ts"],"names":[],"mappings":";;;;;AAAA,gDAAuB;
|
|
1
|
+
{"version":3,"file":"lessImport.js","sourceRoot":"","sources":["../../src/utils/lessImport.ts"],"names":[],"mappings":";;;;;AAAA,gDAAuB;AAEvB,mCAAsC;AAEtC,MAAM,QAAS,SAAQ,cAAI,CAAC,WAAW;IAIrC,YAAa,GAAG;QACd,KAAK,EAAE,CAAA;QAHT,UAAK,GAA2B,EAAE,CAAA;QAIhC,IAAI,CAAC,QAAQ,GAAG,GAAG,CAAC,QAAQ,CAAA;QAC5B,IAAI,CAAC,KAAK,GAAG,GAAG,CAAC,KAAK,CAAA;IACxB,CAAC;IAED,QAAQ;QACN,OAAO,IAAI,CAAA;IACb,CAAC;IAED,YAAY;QACV,OAAO,KAAK,CAAA;IACd,CAAC;IAED,KAAK,CAAC,QAAQ,CACZ,QAAgB,EAChB,gBAAwB,EACxB,OAAY,EACZ,WAAgB;QAEhB,MAAM,WAAW,GAAG;YAClB,OAAO,EAAE,gBAAgB;YACzB,KAAK,EAAE,IAAI,CAAC,KAAK;YACjB,QAAQ,EAAE,IAAI,CAAC,QAAQ;YACvB,UAAU,EAAE,OAAO;SACpB,CAAA;QACD,MAAM,eAAe,GAAG,IAAA,oBAAY,EAAC,QAAQ,EAAE,WAAW,CAAC,CAAA;QAE3D,OAAO,KAAK,CAAC,QAAQ,CAAC,eAAe,EAAE,gBAAgB,EAAE,OAAO,EAAE,WAAW,CAAC,CAAA;IAChF,CAAC;CACF;AAED,SAAS,cAAc,CAAE,OAAO;IAC9B,OAAO;QACL,OAAO,EAAE,CAAC,CAAC,EAAE,aAAa,EAAE,EAAE;YAC5B,aAAa,CAAC,cAAc,CAAC,IAAI,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAA;QACrD,CAAC;QACD,UAAU,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;KACtB,CAAA;AACH,CAAC;AAED,kBAAe,cAAc,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,15 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tarojs/rn-style-transformer",
|
|
3
|
-
"version": "3.5.0-alpha.
|
|
3
|
+
"version": "3.5.0-alpha.16",
|
|
4
4
|
"description": "提供Taro RN 统一处理样式文件能力",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
|
-
"scripts": {
|
|
7
|
-
"test": "jest",
|
|
8
|
-
"test:ci": "jest --silent --coverage false",
|
|
9
|
-
"build": "tsc",
|
|
10
|
-
"dev": "tsc -w",
|
|
11
|
-
"lint": "eslint ."
|
|
12
|
-
},
|
|
13
6
|
"repository": {
|
|
14
7
|
"type": "git",
|
|
15
8
|
"url": "git+https://github.com/NervJS/taro.git"
|
|
@@ -23,25 +16,27 @@
|
|
|
23
16
|
"npm": ">=6.0.0"
|
|
24
17
|
},
|
|
25
18
|
"dependencies": {
|
|
26
|
-
"@tarojs/helper": "3.5.0-alpha.
|
|
19
|
+
"@tarojs/helper": "3.5.0-alpha.16",
|
|
27
20
|
"fbjs": "^2.0.0",
|
|
28
21
|
"less": "^3.12.2",
|
|
29
|
-
"postcss": "^
|
|
22
|
+
"postcss": "^8.4.12",
|
|
30
23
|
"postcss-import": "^12.0.1",
|
|
31
|
-
"postcss-pxtransform": "3.5.0-alpha.
|
|
24
|
+
"postcss-pxtransform": "3.5.0-alpha.16",
|
|
32
25
|
"postcss-reporter": "^6.0.1",
|
|
33
26
|
"prop-types": "^15.7.2",
|
|
27
|
+
"resolve": "^1.22.0",
|
|
34
28
|
"sass": "1.50.0",
|
|
35
|
-
"stylelint": "^
|
|
36
|
-
"stylelint-config-taro-rn": "3.5.0-alpha.
|
|
37
|
-
"stylelint-taro-rn": "3.5.0-alpha.
|
|
29
|
+
"stylelint": "^14.9.1",
|
|
30
|
+
"stylelint-config-taro-rn": "3.5.0-alpha.16",
|
|
31
|
+
"stylelint-taro-rn": "3.5.0-alpha.16",
|
|
38
32
|
"stylus": "^0.55.0",
|
|
39
|
-
"taro-css-to-react-native": "3.5.0-alpha.
|
|
33
|
+
"taro-css-to-react-native": "3.5.0-alpha.16"
|
|
40
34
|
},
|
|
41
|
-
"
|
|
42
|
-
"
|
|
43
|
-
"
|
|
44
|
-
"
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
}
|
|
35
|
+
"scripts": {
|
|
36
|
+
"test": "jest",
|
|
37
|
+
"test:ci": "jest --silent --coverage false",
|
|
38
|
+
"build": "tsc",
|
|
39
|
+
"dev": "tsc -w",
|
|
40
|
+
"lint": "eslint ."
|
|
41
|
+
}
|
|
42
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import * as path from 'path'
|
|
2
|
+
|
|
2
3
|
// import semver from 'semver'
|
|
3
4
|
// import reactNativePKG from 'react-native/package.json'
|
|
4
5
|
import StyleTransform from './transforms'
|
|
@@ -41,3 +42,17 @@ export async function transform (src: string, filename: string, options) {
|
|
|
41
42
|
}
|
|
42
43
|
return upstreamTransformer.transform({ src, filename, options })
|
|
43
44
|
}
|
|
45
|
+
|
|
46
|
+
export function rollupTransform (options) {
|
|
47
|
+
return {
|
|
48
|
+
name: 'rn-style-transformer', // this name will show up in warnings and errors
|
|
49
|
+
async transform (src, filename) {
|
|
50
|
+
const ext = path.extname(filename)
|
|
51
|
+
if (RN_CSS_EXT.includes(ext)) {
|
|
52
|
+
const styleTransform = getSingleStyleTransform((options as any).config)
|
|
53
|
+
const code = await styleTransform.transform(src, filename, options)
|
|
54
|
+
return { code }
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
package/src/transforms/index.ts
CHANGED
|
@@ -1,26 +1,19 @@
|
|
|
1
|
+
import { printLog, processTypeEnum, recursiveMerge } from '@tarojs/helper'
|
|
1
2
|
import * as path from 'path'
|
|
2
3
|
import transformCSS from 'taro-css-to-react-native'
|
|
3
|
-
import { recursiveMerge, printLog, processTypeEnum } from '@tarojs/helper'
|
|
4
4
|
|
|
5
|
+
import { RenderAdditionalResult, TransformOptions } from '../types'
|
|
6
|
+
import { normalizeSourceMap } from '../utils'
|
|
7
|
+
import lessTransform, { Config as LessConfig } from './less'
|
|
5
8
|
import postcssTransform, { Config as PostcssConfig, makePostcssPlugins } from './postcss'
|
|
6
9
|
import sassTransform, { Config as SassConfig, SassGlobalConfig } from './sass'
|
|
7
|
-
import lessTransform, { Config as LessConfig } from './less'
|
|
8
|
-
import stylusTransform, { Config as StylusConfig, defaultOptions as stylusDefaultOptions } from './stylus'
|
|
9
10
|
import { StyleSheetValidation } from './StyleSheet'
|
|
10
|
-
import {
|
|
11
|
-
import { normalizeSourceMap } from '../utils'
|
|
11
|
+
import stylusTransform, { Config as StylusConfig, defaultOptions as stylusDefaultOptions } from './stylus'
|
|
12
12
|
|
|
13
13
|
export function getWrapedCSS (css) {
|
|
14
14
|
return `
|
|
15
|
-
import { StyleSheet
|
|
16
|
-
|
|
17
|
-
// 一般app 只有竖屏模式,所以可以只获取一次 width
|
|
18
|
-
const deviceWidthDp = Dimensions.get('window').width
|
|
19
|
-
const uiWidthPx = 375
|
|
20
|
-
|
|
21
|
-
function scalePx2dp (uiElementPx) {
|
|
22
|
-
return uiElementPx * deviceWidthDp / uiWidthPx
|
|
23
|
-
}
|
|
15
|
+
import { StyleSheet } from 'react-native'
|
|
16
|
+
import { scalePx2dp, scaleVu2dp } from '@tarojs/runtime-rn'
|
|
24
17
|
|
|
25
18
|
// 用来标识 rn-runner transformer 是否读写缓存
|
|
26
19
|
function ignoreStyleFileCache() {}
|
|
@@ -45,18 +38,18 @@ function validateStyle ({ styleObject, filename }) {
|
|
|
45
38
|
}
|
|
46
39
|
|
|
47
40
|
interface RNConfig {
|
|
48
|
-
postcss?: PostcssConfig
|
|
49
|
-
sass?: SassConfig
|
|
50
|
-
less?: LessConfig
|
|
51
|
-
stylus?: StylusConfig
|
|
41
|
+
postcss?: PostcssConfig
|
|
42
|
+
sass?: SassConfig
|
|
43
|
+
less?: LessConfig
|
|
44
|
+
stylus?: StylusConfig
|
|
52
45
|
}
|
|
53
46
|
|
|
54
47
|
interface Config {
|
|
55
|
-
designWidth: number
|
|
56
|
-
deviceRatio: { [key: number]: number }
|
|
57
|
-
sass: SassGlobalConfig
|
|
58
|
-
alias: Record<string, string
|
|
59
|
-
rn: RNConfig
|
|
48
|
+
designWidth: number
|
|
49
|
+
deviceRatio: { [key: number]: number }
|
|
50
|
+
sass: SassGlobalConfig
|
|
51
|
+
alias: Record<string, string>
|
|
52
|
+
rn: RNConfig
|
|
60
53
|
}
|
|
61
54
|
|
|
62
55
|
interface PostcssParam {
|
|
@@ -243,6 +236,7 @@ export default class StyleTransform {
|
|
|
243
236
|
validateStyle({ styleObject, filename })
|
|
244
237
|
const css = JSON.stringify(styleObject, null, 2)
|
|
245
238
|
.replace(/"(scalePx2dp\(.*?\))"/g, '$1')
|
|
239
|
+
.replace(/"(scaleVu2dp\(.*?\))"/g, '$1')
|
|
246
240
|
|
|
247
241
|
// 注入自适应方法 scalePx2dp
|
|
248
242
|
return getWrapedCSS(css)
|
package/src/transforms/less.ts
CHANGED
|
@@ -1,60 +1,61 @@
|
|
|
1
|
-
import * as path from 'path'
|
|
2
1
|
import less from 'less'
|
|
2
|
+
import * as path from 'path'
|
|
3
|
+
|
|
4
|
+
import { RenderAdditionalResult, RenderResult } from '../types'
|
|
5
|
+
import { getAdditionalData, insertBefore } from '../utils'
|
|
3
6
|
import makeLessImport from '../utils/lessImport'
|
|
4
|
-
import { insertBefore, getAdditionalData } from '../utils'
|
|
5
|
-
import { RenderResult, RenderAdditionalResult } from '../types'
|
|
6
7
|
|
|
7
8
|
interface SourceMapOption {
|
|
8
|
-
sourceMapURL?: string
|
|
9
|
-
sourceMapBasepath?: string
|
|
10
|
-
sourceMapRootpath?: string
|
|
11
|
-
outputSourceFiles?: boolean
|
|
12
|
-
sourceMapFileInline?: boolean
|
|
9
|
+
sourceMapURL?: string
|
|
10
|
+
sourceMapBasepath?: string
|
|
11
|
+
sourceMapRootpath?: string
|
|
12
|
+
outputSourceFiles?: boolean
|
|
13
|
+
sourceMapFileInline?: boolean
|
|
13
14
|
}
|
|
14
15
|
// http://lesscss.org/usage/#less-options
|
|
15
16
|
export interface Options {
|
|
16
|
-
sourceMap?: SourceMapOption
|
|
17
|
+
sourceMap?: SourceMapOption
|
|
17
18
|
/** Filename of the main file to be passed to less.render() */
|
|
18
|
-
filename?: string
|
|
19
|
+
filename?: string
|
|
19
20
|
/** The locations for less looking for files in @import rules */
|
|
20
|
-
paths?: string[]
|
|
21
|
+
paths?: string[]
|
|
21
22
|
/** True, if run the less parser and just reports errors without any output. */
|
|
22
|
-
lint?: boolean
|
|
23
|
+
lint?: boolean
|
|
23
24
|
/** Pre-load global Less.js plugins */
|
|
24
|
-
plugins?: Plugin[]
|
|
25
|
+
plugins?: Plugin[]
|
|
25
26
|
/** @deprecated If true, compress using less built-in compression. */
|
|
26
|
-
compress?: boolean
|
|
27
|
-
strictImports?: boolean
|
|
27
|
+
compress?: boolean
|
|
28
|
+
strictImports?: boolean
|
|
28
29
|
/** If true, allow imports from insecure https hosts. */
|
|
29
|
-
insecure?: boolean
|
|
30
|
-
depends?: boolean
|
|
31
|
-
maxLineLen?: number
|
|
30
|
+
insecure?: boolean
|
|
31
|
+
depends?: boolean
|
|
32
|
+
maxLineLen?: number
|
|
32
33
|
/** @deprecated If false, No color in compiling. */
|
|
33
|
-
color?: boolean
|
|
34
|
+
color?: boolean
|
|
34
35
|
/** @deprecated False by default. */
|
|
35
|
-
ieCompat?: boolean
|
|
36
|
+
ieCompat?: boolean
|
|
36
37
|
/** @deprecated If true, enable evaluation of JavaScript inline in `.less` files. */
|
|
37
|
-
javascriptEnabled?: boolean
|
|
38
|
+
javascriptEnabled?: boolean
|
|
38
39
|
/** Whether output file information and line numbers in compiled CSS code. */
|
|
39
|
-
dumpLineNumbers?: 'comment' | string
|
|
40
|
+
dumpLineNumbers?: 'comment' | string
|
|
40
41
|
/** Add a path to every generated import and url in output css files. */
|
|
41
|
-
rootpath?: string
|
|
42
|
+
rootpath?: string
|
|
42
43
|
/** Math mode options for avoiding symbol conficts on math expressions. */
|
|
43
|
-
math?: 'always' | 'strict' | 'parens-division' | 'parens' | 'strict-legacy' | number
|
|
44
|
+
math?: 'always' | 'strict' | 'parens-division' | 'parens' | 'strict-legacy' | number
|
|
44
45
|
/** If true, stops any warnings from being shown. */
|
|
45
|
-
silent?: boolean
|
|
46
|
+
silent?: boolean
|
|
46
47
|
/** Without this option, Less attempts to guess at the output unit when it does maths. */
|
|
47
|
-
strictUnits?: boolean
|
|
48
|
+
strictUnits?: boolean
|
|
48
49
|
/** Defines a variable that can be referenced by the file. */
|
|
49
50
|
globalVars?: {
|
|
50
|
-
[key: string]: string
|
|
51
|
-
}
|
|
51
|
+
[key: string]: string
|
|
52
|
+
}
|
|
52
53
|
/** Puts Var declaration at the end of base file. */
|
|
53
54
|
modifyVars?: {
|
|
54
|
-
[key: string]: string
|
|
55
|
-
}
|
|
55
|
+
[key: string]: string
|
|
56
|
+
}
|
|
56
57
|
/** Read files synchronously in Node.js */
|
|
57
|
-
syncImport?: boolean
|
|
58
|
+
syncImport?: boolean
|
|
58
59
|
}
|
|
59
60
|
|
|
60
61
|
export interface Config {
|
|
@@ -1,20 +1,21 @@
|
|
|
1
|
+
import { isNpmPkg, printLog, processTypeEnum, recursiveMerge } from '@tarojs/helper'
|
|
1
2
|
import * as path from 'path'
|
|
2
|
-
import { sync as resolveSync } from 'resolve'
|
|
3
3
|
import postcss, { ProcessOptions } from 'postcss'
|
|
4
|
-
import pxtransform from 'postcss-pxtransform'
|
|
5
4
|
import postcssImport from 'postcss-import'
|
|
6
|
-
import
|
|
5
|
+
import pxtransform from 'postcss-pxtransform'
|
|
6
|
+
import { sync as resolveSync } from 'resolve'
|
|
7
|
+
|
|
8
|
+
import stylelintConfig from '../config/rn-stylelint.json'
|
|
7
9
|
import { resolveStyle } from '../utils'
|
|
8
10
|
import reporterSkip from '../utils/reporterSkip'
|
|
9
|
-
import stylelintConfig from '../config/rn-stylelint.json'
|
|
10
11
|
|
|
11
12
|
export interface Config {
|
|
12
|
-
options: ProcessOptions
|
|
13
|
-
scalable: boolean
|
|
13
|
+
options: ProcessOptions // https://github.com/postcss/postcss#options
|
|
14
|
+
scalable: boolean // 控制是否对 css value 进行 scalePx2dp 转换
|
|
14
15
|
pxtransform: {
|
|
15
|
-
enable: boolean
|
|
16
|
-
config: any
|
|
17
|
-
}
|
|
16
|
+
enable: boolean
|
|
17
|
+
config: any
|
|
18
|
+
}
|
|
18
19
|
}
|
|
19
20
|
|
|
20
21
|
const defaultPxtransformOption: {
|
package/src/transforms/sass.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import * as fs from 'fs'
|
|
2
2
|
import * as path from 'path'
|
|
3
3
|
import { Options } from 'sass'
|
|
4
|
-
|
|
5
|
-
import {
|
|
4
|
+
|
|
5
|
+
import { RenderAdditionalResult, RenderResult, TransformOptions } from '../types'
|
|
6
|
+
import { getAdditionalData, insertAfter, insertBefore, resolveStyle } from '../utils'
|
|
6
7
|
|
|
7
8
|
/**
|
|
8
9
|
* 用过用户手动安装了 node-sass,启用node-sass,默认使用 sass
|
|
@@ -35,9 +36,9 @@ export interface Config {
|
|
|
35
36
|
}
|
|
36
37
|
|
|
37
38
|
export interface SassGlobalConfig {
|
|
38
|
-
resource?: string | string[]
|
|
39
|
-
projectDirectory?: string
|
|
40
|
-
data?: string
|
|
39
|
+
resource?: string | string[]
|
|
40
|
+
projectDirectory?: string
|
|
41
|
+
data?: string
|
|
41
42
|
}
|
|
42
43
|
|
|
43
44
|
function makeURL (resource: string, rootDir: string) {
|
package/src/transforms/stylus.ts
CHANGED
|
@@ -1,21 +1,22 @@
|
|
|
1
1
|
import stylus from 'stylus'
|
|
2
|
-
|
|
2
|
+
|
|
3
|
+
import { RenderAdditionalResult, RenderResult } from '../types'
|
|
3
4
|
import { getAdditionalData, insertBefore } from '../utils'
|
|
4
5
|
|
|
5
6
|
class Evaluator { }
|
|
6
7
|
|
|
7
8
|
interface Dictionary<T> {
|
|
8
|
-
[key: string]: T
|
|
9
|
+
[key: string]: T
|
|
9
10
|
}
|
|
10
11
|
|
|
11
12
|
// https://stylus-lang.com/docs/js.html
|
|
12
13
|
interface RenderOptions {
|
|
13
|
-
globals?: Dictionary<any
|
|
14
|
-
functions?: Dictionary<any
|
|
15
|
-
imports?: string[]
|
|
16
|
-
paths?: string[]
|
|
17
|
-
filename?: string
|
|
18
|
-
Evaluator?: typeof Evaluator
|
|
14
|
+
globals?: Dictionary<any>
|
|
15
|
+
functions?: Dictionary<any>
|
|
16
|
+
imports?: string[]
|
|
17
|
+
paths?: string[]
|
|
18
|
+
filename?: string
|
|
19
|
+
Evaluator?: typeof Evaluator
|
|
19
20
|
/**
|
|
20
21
|
* Specify Stylus plugins to use. Plugins may be passed as
|
|
21
22
|
* strings instead of importing them in your Webpack config.
|
|
@@ -23,21 +24,21 @@ interface RenderOptions {
|
|
|
23
24
|
* @type {(string|Function)[]}
|
|
24
25
|
* @default []
|
|
25
26
|
*/
|
|
26
|
-
use: (string | ((string) => string))[]
|
|
27
|
+
use: (string | ((string) => string))[]
|
|
27
28
|
/**
|
|
28
29
|
* Add path(s) to the import lookup paths.
|
|
29
30
|
*
|
|
30
31
|
* @type {string[]}
|
|
31
32
|
* @default []
|
|
32
33
|
*/
|
|
33
|
-
include: string[]
|
|
34
|
+
include: string[]
|
|
34
35
|
/**
|
|
35
36
|
* Import the specified Stylus files/paths.
|
|
36
37
|
*
|
|
37
38
|
* @type {string[]}
|
|
38
39
|
* @default []
|
|
39
40
|
*/
|
|
40
|
-
import: string[]
|
|
41
|
+
import: string[]
|
|
41
42
|
|
|
42
43
|
/**
|
|
43
44
|
* Define Stylus variables or functions.
|
|
@@ -46,7 +47,7 @@ interface RenderOptions {
|
|
|
46
47
|
* @default {}
|
|
47
48
|
*/
|
|
48
49
|
// Array is the recommended syntax: [key, value, raw]
|
|
49
|
-
define: Array<any> | Record<string, any
|
|
50
|
+
define: Array<any> | Record<string, any>
|
|
50
51
|
// Object is deprecated syntax (there is no possibility to specify "raw')
|
|
51
52
|
// define: {
|
|
52
53
|
// $development: process.env.NODE_ENV === 'development',
|
|
@@ -59,7 +60,7 @@ interface RenderOptions {
|
|
|
59
60
|
* @type {boolean}
|
|
60
61
|
* @default false
|
|
61
62
|
*/
|
|
62
|
-
includeCSS: boolean
|
|
63
|
+
includeCSS: boolean
|
|
63
64
|
|
|
64
65
|
/**
|
|
65
66
|
* Resolve relative url()'s inside imported files.
|
|
@@ -80,12 +81,12 @@ interface RenderOptions {
|
|
|
80
81
|
* @type {boolean}
|
|
81
82
|
* @default false
|
|
82
83
|
*/
|
|
83
|
-
lineNumbers: boolean
|
|
84
|
+
lineNumbers: boolean
|
|
84
85
|
/**
|
|
85
86
|
* @type {boolean}
|
|
86
87
|
* @default false
|
|
87
88
|
*/
|
|
88
|
-
disableCache: boolean
|
|
89
|
+
disableCache: boolean
|
|
89
90
|
|
|
90
91
|
/**
|
|
91
92
|
* Move @import and @charset to the top.
|
|
@@ -95,7 +96,7 @@ interface RenderOptions {
|
|
|
95
96
|
* @type {boolean}
|
|
96
97
|
* @default false
|
|
97
98
|
*/
|
|
98
|
-
hoistAtrules: boolean
|
|
99
|
+
hoistAtrules: boolean
|
|
99
100
|
}
|
|
100
101
|
|
|
101
102
|
export interface Config {
|
package/src/utils/index.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
|
+
import { printLog, processTypeEnum } from '@tarojs/helper'
|
|
1
2
|
import * as fs from 'fs'
|
|
2
3
|
import * as path from 'path'
|
|
3
|
-
import { printLog, processTypeEnum } from '@tarojs/helper'
|
|
4
|
-
import { ResolveStyleOptions, LogLevelEnum } from '../types'
|
|
5
4
|
import * as resolve from 'resolve'
|
|
6
5
|
import nodeModulesPaths from 'resolve/lib/node-modules-paths'
|
|
7
6
|
|
|
7
|
+
import { LogLevelEnum, ResolveStyleOptions } from '../types'
|
|
8
|
+
|
|
8
9
|
export function insertBefore (source?: string, additional?: string) {
|
|
9
10
|
if (!source && !additional) {
|
|
10
11
|
return ''
|