@tmsfe/tmskit 0.0.2 → 0.0.5-beta.1

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.
@@ -1,15 +1,15 @@
1
1
  const shelljs = require('shelljs');
2
- const webpackBuildServer = require('../../../webpack/buildServer');
3
2
  const { resolve } = require('../../../utils/widgets');
4
3
  const init = require('../init/index');
4
+ const gulpBuild = require('../../../gulp/build');
5
5
 
6
6
  async function build(tmsConfig, targetModules, env) {
7
7
  // 开始构建前,清理输出目录
8
- await shelljs.rm('-rf', resolve('dist'));
8
+ await shelljs.rm('-rf', resolve(tmsConfig.gulp.outputDir));
9
9
 
10
10
  const { targetModules: newModules } = await init(tmsConfig, targetModules);
11
11
 
12
- webpackBuildServer(tmsConfig, newModules, env);
12
+ gulpBuild(tmsConfig, newModules, env);
13
13
  }
14
14
 
15
15
  module.exports = build;
@@ -1,4 +1,4 @@
1
- const webpackServer = require('../../../webpack/devServer');
1
+ const gulpDev = require('../../../gulp/dev');
2
2
  const fs = require('fs');
3
3
  const { resolve } = require('../../../utils/widgets');
4
4
  const init = require('../init/index');
@@ -45,7 +45,7 @@ function isInit(tmsConfig, targetModules, contextDir) {
45
45
  }
46
46
 
47
47
  // 判断package.json的版本是否有新的版本
48
- return checkDependencies(targetModules, resolve('./'), tmsConfig.webpack.outputDir);
48
+ return checkDependencies(targetModules, resolve('./'), tmsConfig.gulp.outputDir);
49
49
  }
50
50
 
51
51
  async function dev(tmsConfig, targetModules, env) {
@@ -60,7 +60,7 @@ async function dev(tmsConfig, targetModules, env) {
60
60
  }
61
61
 
62
62
  console.log('当前dev启动的有效模块', newModules.map(item => item.name));
63
- webpackServer(tmsConfig, newModules, env);
63
+ gulpDev(tmsConfig, newModules, env);
64
64
  }
65
65
 
66
66
  module.exports = dev;
@@ -1,7 +1,8 @@
1
1
  const init = require('./init/index');
2
2
  const dev = require('./dev/index');
3
3
  const build = require('./build/index');
4
- const { createTask } = require('../../utils/widgets');
4
+ const install = require('./install/index');
5
+ const { createTask } = require('../../utils/widgets');
5
6
  const { MODE } = require('../../config/constant');
6
7
  const { readTmsConfig, checkModules } = require('../../utils/tkitUtils');
7
8
 
@@ -11,10 +12,12 @@ const handleModulesArg = (cmd) => {
11
12
  return MODE.main;
12
13
  }
13
14
  // 单模块 或 多模块开发
15
+ const { argv } = process;
16
+ const reset = argv.indexOf('-m') > -1 ? argv.slice(argv.indexOf('-m') + 1) : [];
14
17
  if (cmd.module) {
15
18
  return [
16
19
  cmd.module,
17
- ...cmd.args,
20
+ ...reset,
18
21
  ];
19
22
  }
20
23
  // 全量模块
@@ -46,6 +49,9 @@ async function run(commandName, cmd) {
46
49
  case 'dev':
47
50
  dev(tmsConfig, modules, env);
48
51
  return;
52
+ case 'install':
53
+ install(tmsConfig, modules, env);
54
+ return;
49
55
  case 'build':
50
56
  build(tmsConfig, modules, env);
51
57
  return;
@@ -3,44 +3,38 @@ const fs = require('fs');
3
3
  const io = require('../../../utils/io');
4
4
  const { resolve, createTask } = require('../../../utils/widgets');
5
5
  const { buildOutputAppJson } = require('../../../utils/buildAppJson');
6
- const { npmInstallAll } = require('../../../utils/npmUtils');
7
- const { buildMpNpm } = require('../../../utils/mpCiUtils');
8
- const { MODULE_CODE_DIR, CACHE_DIR, DEFAULT_COPY_CONFIG, DEFAULT_MODULE_DIR } = require('../../../config/constant');
6
+ const { MODULE_CODE_DIR, DEFAULT_COPY_CONFIG, DEFAULT_MODULE_DIR } = require('../../../config/constant');
9
7
  const { cloneModules } = require('../../../utils/cloneModules');
10
8
  const { tmsModulesMergeLocalModuleCfg } = require('../../../utils/tkitUtils');
11
9
  const { fail } = require('../../../utils/log');
10
+ const install = require('../install');
12
11
 
13
12
  /**
14
- * 拷贝package.json\模块的代码到编译输出目录
13
+ * 拷贝相关配置文件到编译输出目录
15
14
  * @param { object } tmsConfig
16
15
  * @param { array } modules
17
16
  * @param { array } defaultFiles 默认需要拷贝的配置项
18
17
  * @returns
19
18
  */
20
19
  const cpFilesToOutput = function (tmsConfig, targetModules, defaultFiles) {
21
- const outputDir = resolve(tmsConfig.webpack.outputDir);
20
+ const outputDir = resolve(tmsConfig.gulp.outputDir);
22
21
  io.ensureDirExist(outputDir);
23
22
  defaultFiles.forEach((item) => {
24
23
  if (fs.existsSync(resolve(item))) {
25
- shelljs.cp('-rf', resolve(item), resolve(tmsConfig.webpack.outputDir, item));
24
+ shelljs.cp('-rf', resolve(item), resolve(tmsConfig.gulp.outputDir, item));
26
25
  }
27
26
  });
28
27
 
29
- // 拷贝模块的代码到编译输出目录
28
+ // 拷贝模块的package.json到编译输出目录
30
29
  targetModules.forEach((item) => {
31
- const outputModuleDir = resolve(`${tmsConfig.webpack.outputDir}/${item.root}`);
30
+ const outputModuleDir = resolve(`${tmsConfig.gulp.outputDir}/${item.root}`);
32
31
  if (!fs.existsSync(resolve(item.path))) {
33
32
  fail(`${item.path}模块代码路径不存在, 请检查tms.config.js的${item.name}模块的path`);
34
33
  process.exit(1);
35
34
  }
36
- if (!fs.existsSync(outputModuleDir)) {
37
- shelljs.mkdir('-p', outputModuleDir);
38
- } else {
39
- // 删除除了node_modules、miniprogram_npm 的其他文件
40
- // eslint-disable-next-line
41
- shelljs.exec('find . -not \( -name node_modules -or -name miniprogram_npm \) -delete', { silent: true });
42
- }
43
- shelljs.cp('-Rf', `${resolve(item.path)}/*`, outputModuleDir);
35
+ io.ensureDirExist(outputModuleDir);
36
+ const modulePackagePath = resolve(item.path, 'package.json');
37
+ if (fs.existsSync(modulePackagePath)) shelljs.cp('-Rf', modulePackagePath, outputModuleDir);
44
38
  });
45
39
  };
46
40
 
@@ -63,19 +57,8 @@ async function task(tmsConfig, targetModules) {
63
57
  '拷贝文件到编译输出目录完成',
64
58
  )(tmsConfig, newModules, DEFAULT_COPY_CONFIG);
65
59
 
66
- // npm install
67
- await createTask(
68
- npmInstallAll,
69
- '开始npm install',
70
- 'npm install 完成',
71
- )(newModules, resolve(tmsConfig.webpack.outputDir), `${CACHE_DIR}/node_modules`);
72
-
73
- // 构建miniprograme_npm
74
- await createTask(
75
- buildMpNpm,
76
- '开始构建miniprograme_npm',
77
- '构建miniprograme_npm 完成',
78
- )({ appId: tmsConfig.appId, projectPath: resolve('./'), privateKey: tmsConfig.privateKey });
60
+ // install
61
+ await install(tmsConfig, newModules, false);
79
62
 
80
63
  // 动态生成编译后的app.json;
81
64
  await createTask(
@@ -0,0 +1,31 @@
1
+ const { createTask, resolve } = require('../../../utils/widgets');
2
+ const { buildMpNpm } = require('../../../utils/mpCiUtils');
3
+ const { CACHE_DIR, DEFAULT_MODULE_DIR } = require('../../../config/constant');
4
+ const { cloudNpmInstall, mpNpmInstallAll } = require('../../../utils/npmUtils');
5
+ const { tmsModulesMergeLocalModuleCfg } = require('../../../utils/tkitUtils');
6
+
7
+ async function install(tmsConfig, modules, isCloud = true) {
8
+ const newModules = tmsModulesMergeLocalModuleCfg(modules, tmsConfig.appName, DEFAULT_MODULE_DIR);
9
+ // 小程序npm install
10
+ await createTask(
11
+ mpNpmInstallAll,
12
+ '小程序 开始npm install',
13
+ '小程序npm install 完成',
14
+ )(newModules, resolve(tmsConfig.gulp.outputDir), `${CACHE_DIR}/node_modules`);
15
+
16
+ // 构建miniprograme_npm
17
+ await createTask(
18
+ buildMpNpm,
19
+ '开始构建miniprograme_npm',
20
+ '构建miniprograme_npm 完成',
21
+ )({ appId: tmsConfig.appId, projectPath: resolve('./'), privateKey: tmsConfig.privateKey });
22
+
23
+ // 安装云函数的
24
+ isCloud && createTask(
25
+ cloudNpmInstall,
26
+ '云函数npm install',
27
+ '云函数npm install安装完毕',
28
+ )(resolve(tmsConfig.cloudDir));
29
+ }
30
+
31
+ module.exports = install;
@@ -133,7 +133,7 @@ function buildOutputAppJson(tmsConfig, modules) {
133
133
  // 更新主包,需在subpackages处理完成后执行, pages/
134
134
  updateMainPackages(appJson, tmsConfig.mainPackages, DEFAULT_MODULE_DIR);
135
135
 
136
- fs.writeFileSync(resolve(`${tmsConfig.webpack.outputDir}/app.json`), JSON.stringify(appJson, null, 2), 'utf8');
136
+ fs.writeFileSync(resolve(`${tmsConfig.gulp.outputDir}/app.json`), JSON.stringify(appJson, null, 2), 'utf8');
137
137
 
138
138
  return appJson;
139
139
  }
package/src/utils/io.js CHANGED
@@ -1,4 +1,5 @@
1
1
  const fs = require('fs');
2
+ const path = require('path');
2
3
  /**
3
4
  * 判断目录是否为空
4
5
  * @param {string} dirname 目录名
@@ -15,7 +16,51 @@ const ensureDirExist = (dirname) => {
15
16
  }
16
17
  };
17
18
 
19
+ // 复制文件
20
+ const copyFile = function (src, dest) {
21
+ if (fs.existsSync(dest)) {
22
+ fs.unlinkSync(dest);
23
+ }
24
+ const dir = dest.substr(0, dest.lastIndexOf('/'));
25
+ ensureDirExist(dir);
26
+ fs.copyFileSync(src, dest);
27
+ };
28
+
29
+ // 添加后缀
30
+ function ext(filePath, extensions) {
31
+ let newFilePath = filePath;
32
+ try {
33
+ const stat = fs.lstatSync(newFilePath);
34
+ if (stat.isDirectory()) {
35
+ newFilePath += (newFilePath[newFilePath.length - 1] === '/') ? 'index' : '/index';
36
+ }
37
+ } catch (e) {}
38
+
39
+ for (const ext of extensions) {
40
+ const file = newFilePath.endsWith(ext) ? newFilePath : newFilePath + ext;
41
+ if (fs.existsSync(file)) {
42
+ return {
43
+ file,
44
+ ext,
45
+ };
46
+ }
47
+ }
48
+ return null;
49
+ }
50
+
51
+ // 判断文件是否在某个目录
52
+ const fileInDir = (dir, file) => {
53
+ const relativePath = path.relative(dir, file);
54
+ if (relativePath.startsWith('..')) {
55
+ return false;
56
+ }
57
+ return true;
58
+ };
59
+
18
60
  module.exports = {
19
61
  isDirEmpty,
62
+ copyFile,
20
63
  ensureDirExist,
64
+ ext,
65
+ fileInDir,
21
66
  };
@@ -4,11 +4,12 @@
4
4
  const fs = require('fs');
5
5
  const path = require('path');
6
6
  const shell = require('shelljs');
7
+ const glob = require('glob-ignore');
7
8
  const LOG = require('./log');
8
9
 
9
10
  const dirpath = process.cwd(); // 项目根目录
10
11
 
11
- const getTarNpmFilename = targetDir => `${targetDir.replaceAll('/', '-')}.tar.gz`;
12
+ const getTarNpmFilename = targetDir => `${targetDir.replace(/\//g, '-')}.tar.gz`;
12
13
 
13
14
  // 缓存npm包
14
15
  const npmCache = function (targetDir, cacheDir) {
@@ -38,9 +39,8 @@ const getNpmCache = function (targetDir, cacheDir) {
38
39
 
39
40
 
40
41
  // 遍历安装指定目录下所有项目的npm依赖
41
- const npmInstallAll = async (modules, contextDir, cacheDir) => {
42
+ const mpNpmInstallAll = async (modules, contextDir, cacheDir) => {
42
43
  const packageJsonFiles = await findAllPackageJson(modules, contextDir);
43
-
44
44
  await Promise.all(packageJsonFiles.map(file => new Promise((resolve) => {
45
45
  const dir = path.dirname(file);
46
46
  shell.cd(dir);
@@ -109,7 +109,12 @@ const findAllPackageJson = (subRoots = [], contextDir) => {
109
109
  const cwd = contextDir || dirpath;
110
110
  const result = [path.join(cwd, packageJsonName)]; // 默认填充根目录下的package.json
111
111
 
112
+
112
113
  subRoots.forEach((subRoot) => {
114
+ if (!subRoot.root) {
115
+ LOG.fail(`请检查${subRoot.name}的module.config.json是否有root字段`);
116
+ process.exit(1);
117
+ }
113
118
  const toppath = path.join(cwd, subRoot.root); // 从该目录开始查找package.json文件
114
119
  const list = findFilesByFilter(toppath, packageJsonName);
115
120
 
@@ -119,8 +124,25 @@ const findAllPackageJson = (subRoots = [], contextDir) => {
119
124
  return result;
120
125
  };
121
126
 
127
+ function cloudNpmInstall(contextDir) {
128
+ return new Promise((resolve, reject) => {
129
+ glob(`${contextDir}/**/package.json`, ['node_modules', 'miniprogram_npm'], (err, files) => {
130
+ if (err) {
131
+ reject(err);
132
+ }
133
+ files.forEach((file) => {
134
+ const dir = path.dirname(file);
135
+ shell.cd(dir);
136
+ shell.exec('npx npm install --production --registry http://mirrors.tencent.com/npm/', { silent: false });
137
+ });
138
+ resolve();
139
+ });
140
+ });
141
+ }
142
+
122
143
 
123
144
  module.exports = {
124
- npmInstallAll,
145
+ cloudNpmInstall,
146
+ mpNpmInstallAll,
125
147
  findAllPackageJson,
126
148
  };
@@ -96,7 +96,7 @@ function downloadRepo(dest, downloadOptions = { repoUrl: '', gitUrl: '', branch:
96
96
  function downloadRepoForGit(url, dest, branch) {
97
97
  const cwd = process.cwd();
98
98
 
99
- return new Promise((resolve, reject) => {
99
+ return new Promise((resolve) => {
100
100
  // 如果目标目录不存在
101
101
  if (fs.existsSync(dest)) {
102
102
  shelljs.rm('-rf', path.join(dest));
@@ -105,17 +105,10 @@ function downloadRepoForGit(url, dest, branch) {
105
105
  shelljs.mkdir('-p', dest);
106
106
  shelljs.cd(dest);
107
107
 
108
- shelljs.exec(`git clone ${url} ${dest} --depth=1`, shelljsOptons);
109
-
110
- shelljs.exec(`git checkout ${branch}`, (code) => {
111
- if (code === 0) {
112
- shelljs.cd(cwd);
108
+ shelljs.exec(`git clone ${url} ${dest} --branch ${branch} --depth 1`, shelljsOptons);
113
109
 
114
- resolve();
115
- }
116
-
117
- reject();
118
- });
110
+ shelljs.cd(cwd);
111
+ resolve();
119
112
  });
120
113
  }
121
114
 
@@ -1,65 +0,0 @@
1
- const WebpackChain = require('webpack-chain');
2
- const webpack = require('webpack');
3
- const { getEntry, stringified, getAlias } = require('./utils');
4
- const { resolve } = require('../utils/widgets');
5
- const { DEFAULT_WEBPACK_ENTRY, DEFAULT_MODULE_DIR } = require('../config/constant');
6
-
7
- module.exports = (tmsConfig, modules) => {
8
- const { envData = {}, webpack: tmsWebpack } = tmsConfig;
9
- let webpackConfig = new WebpackChain();
10
-
11
- const alias = getAlias(modules);
12
- const entry = getEntry(DEFAULT_WEBPACK_ENTRY, modules, tmsConfig, DEFAULT_MODULE_DIR);
13
- webpackConfig.merge({
14
- entry,
15
- output: {
16
- path: resolve(`./${tmsWebpack.outputDir}`),
17
- libraryTarget: 'commonjs2',
18
- filename: '[name]',
19
- },
20
- // TODO 有报错,先注释掉
21
- // cache: {
22
- // type: 'filesystem',
23
- // cacheDirectory: resolve(`./${tmsConfig.webpack.outputDir}/node_modules/.cache`),
24
- // },
25
- resolve: {
26
- extensions: ['.tsx', '.ts', '.js'],
27
- alias: Object.assign(tmsWebpack.alias, alias),
28
- },
29
- devtool: tmsWebpack.sourceMap ? 'source-map' : false,
30
- });
31
-
32
- webpackConfig.module
33
- .rule('ts-loader')
34
- .test(/\.ts$/)
35
- .use('ts-loader')
36
- .loader(require.resolve('ts-loader'))
37
- .options({
38
- configFile: resolve('./tsconfig.json'),
39
- // 只进行语法转换,不进行类型校验,提高构建速度
40
- transpileOnly: true,
41
- })
42
- .end();
43
-
44
- // webpackConfig.module
45
- // .rule('babel')
46
- // .test(/\.(js|mjs|jsx|ts|tsx)$/)
47
- // .pre()
48
- // .exclude.add(/(node_modules|miniprogram_npm)/).end()
49
- // .use(require.resolve('babel-loader'))
50
- // .loader(require.resolve('babel-loader'));
51
-
52
- webpackConfig
53
- .plugin('definePlugin')
54
- .use(webpack.DefinePlugin, [stringified(envData)])
55
- .end();
56
-
57
- // 执行tms.config.js自定义的webpackChain
58
- if (tmsWebpack.webpackChain) {
59
- webpackConfig = tmsWebpack.webpackChain(webpackConfig, {
60
- modules,
61
- });
62
- }
63
-
64
- return webpackConfig;
65
- };
@@ -1,21 +0,0 @@
1
- const webpackConfig = require('./base');
2
- const { DEFAULT_COPY_CONFIG } = require('../config/constant');
3
- const { getCopyPlugin } = require('./utils');
4
-
5
- module.exports = (...args) => {
6
- const [tmsConfig, modules] = args;
7
- const webpackBuildConfig = webpackConfig(...args);
8
-
9
- webpackBuildConfig.mode('production');
10
-
11
- const copyPluginParams = getCopyPlugin(DEFAULT_COPY_CONFIG, modules, tmsConfig, 'build');
12
- // console.log('copyPluginParams', copyPluginParams);
13
- webpackBuildConfig
14
- .plugin('copy-webpack-plugin')
15
- .use(require('copy-webpack-plugin'), [{
16
- patterns: copyPluginParams,
17
- }])
18
- .end();
19
-
20
- return webpackBuildConfig;
21
- };
@@ -1,34 +0,0 @@
1
- const webpack = require('webpack');
2
- const webBuildConfig = require('./build');
3
- const { createTask } = require('../utils/widgets');
4
- const { fail } = require('../utils/log');
5
-
6
- function compilerRun(compiler) {
7
- return new Promise((resolve) => {
8
- compiler.run((err, stats) => {
9
- resolve({ err, stats });
10
- });
11
- });
12
- }
13
-
14
- module.exports = async (...args) => {
15
- const config = webBuildConfig(...args);
16
- const compiler = webpack(config.toConfig());
17
-
18
- const { err, stats } = await createTask(compilerRun, '开始webpack打包编译', 'webpack打包编译完成')(compiler);;
19
-
20
- if (err) {
21
- fail(err);
22
- console.log('详细的错误信息:', err);
23
- }
24
-
25
- if (stats.hasErrors() || stats.hasWarnings()) {
26
- console.log(stats.toString({
27
- // 增加控制台颜色开关
28
- colors: true,
29
- errorDetails: true,
30
- }));
31
- };
32
-
33
- return compiler;
34
- };
@@ -1,31 +0,0 @@
1
- const webpackConfig = require('./base');
2
- const { DEFAULT_COPY_CONFIG } = require('../config/constant');
3
- const { getCopyPlugin } = require('./utils');
4
-
5
- module.exports = (...args) => {
6
- const [tmsConfig, modules] = args;
7
- const webpackDevConfig = webpackConfig(...args);
8
-
9
- webpackDevConfig.devtool('source-map');
10
-
11
- webpackDevConfig.mode('development');
12
-
13
- const copyPluginParams = getCopyPlugin(DEFAULT_COPY_CONFIG, modules, tmsConfig, 'dev');
14
- // console.log('copyPluginParams', copyPluginParams);
15
- webpackDevConfig
16
- .plugin('copy-webpack-plugin')
17
- .use(require('copy-webpack-plugin'), [{
18
- patterns: copyPluginParams,
19
- }])
20
- .end();
21
-
22
- webpackDevConfig
23
- .plugin('ExtractPlugin')
24
- .use(require('./plugins/entryExtractPlugin'), [{
25
- tmsConfig,
26
- modules,
27
- }])
28
- .end();
29
-
30
- return webpackDevConfig;
31
- };
@@ -1,37 +0,0 @@
1
- const webpack = require('webpack');
2
- const webDevConfig = require('./dev');
3
- const { setupDevWebPackHooks } = require('./utils');
4
- const { fail } = require('../utils/log');
5
-
6
- module.exports = (...args) => {
7
- const config = webDevConfig(...args);
8
- const compiler = webpack(config.toConfig());
9
-
10
- setupDevWebPackHooks({
11
- compiler,
12
- }, () => {
13
- // TODO 判断open参数,打开微信开发者工具
14
- // openDevtool(api.resolve(config.outputDir || 'dist'))
15
- });
16
-
17
- compiler.watch(
18
- {
19
- aggregateTimeout: 1000,
20
- poll: undefined,
21
- },
22
- (err, stats) => {
23
- if (err) {
24
- fail(err);
25
- console.log('详细的错误信息:', err);
26
- }
27
- if (stats.hasErrors() || stats.hasWarnings()) {
28
- console.log(stats.toString({
29
- // 增加控制台颜色开关
30
- colors: true,
31
- }));
32
- };
33
- },
34
- );
35
-
36
- return compiler;
37
- };
@@ -1,29 +0,0 @@
1
- const SingleEntryPlugin = require('webpack/lib/SingleEntryPlugin');
2
- const { DEFAULT_WEBPACK_ENTRY, DEFAULT_MODULE_DIR } = require('../../../config/constant');
3
- const { getEntry } = require('../../utils');
4
-
5
- class EntryExtraPlugin {
6
- constructor(options = {}) {
7
- this.options = options;
8
- this.scriptExtensions = options.scriptExtensions || ['.ts', '.js'];
9
- }
10
-
11
- applyEntry(compiler, entry) {
12
- const { context } = compiler.options;
13
-
14
- Object.keys(entry).forEach((key) => {
15
- new SingleEntryPlugin(context, entry[key], key).apply(compiler);
16
- });
17
- }
18
-
19
- apply(compiler) {
20
- const { tmsConfig = {}, modules = [] } = this.options;
21
-
22
- compiler.hooks.watchRun.tap('EntryExtraPlugin', () => {
23
- const entry = getEntry(DEFAULT_WEBPACK_ENTRY, modules, tmsConfig, DEFAULT_MODULE_DIR);
24
- this.applyEntry(compiler, entry);
25
- });
26
- }
27
- }
28
-
29
- module.exports = EntryExtraPlugin;
@@ -1,14 +0,0 @@
1
- const px2rpx = postcss.plugin('postcss-px2rpx', (opts = {}) => {
2
- const { proportion = 1, minPixelValue = 0 } = opts;
3
-
4
- return (root) => {
5
- root.replaceValues(pxRegExp, { fast: 'px' }, (string) => {
6
- const pixels = parseInt(string, 10);
7
- if (pixels < minPixelValue) return `${pixels}px`;
8
- return `${proportion * parseInt(string, 10)}rpx`;
9
- });
10
- };
11
- });
12
-
13
-
14
- export default px2rpx;