@tmsfe/tmskit 0.0.1 → 0.0.5-beta.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.
@@ -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
  }
@@ -0,0 +1,150 @@
1
+ const path = require('path');
2
+ const fs = require('fs');
3
+ const { resolve, unique } = require('../utils/widgets');
4
+ const { tmsModulesMergeLocalModuleCfg } = require('../utils/tkitUtils');
5
+ const { fail } = require('../utils/log');
6
+ const replaceExt = require('replace-ext');
7
+
8
+ const extensions = ['.js', '.ts'];
9
+ function ext(entry, extensions) {
10
+ let newEntry = entry;
11
+ try {
12
+ const stat = fs.lstatSync(newEntry);
13
+ if (stat.isDirectory()) {
14
+ newEntry += (newEntry[newEntry.length - 1] === '/') ? 'index' : '/index';
15
+ }
16
+ } catch (e) {}
17
+
18
+ for (const ext of extensions) {
19
+ const file = replaceExt(newEntry, ext);
20
+ if (fs.existsSync(file)) {
21
+ return {
22
+ file,
23
+ ext,
24
+ };
25
+ }
26
+ }
27
+ return null;
28
+ }
29
+
30
+ // 根据用户选择的modules,找到module.config.json的配置信息,找到所有的page
31
+ function getPageEntry(modules, tmsConfig, moduleDir) {
32
+ let entry = [];
33
+ // tms.config.js的modules 合并 module.config.json的配置项
34
+ const newModules = tmsModulesMergeLocalModuleCfg(modules, tmsConfig.appName, moduleDir);
35
+ newModules.forEach(({ path: relativePath, pages, root }, index) => {
36
+ pages.forEach((page) => {
37
+ const pageJsonPath = `${resolve(relativePath, page)}.json`;
38
+ if (fs.existsSync(pageJsonPath)) {
39
+ const pageJsonContent = JSON.parse(fs.readFileSync(pageJsonPath, 'utf-8'));
40
+ const pageDir = path.dirname(pageJsonPath); // 该页面所在的目录
41
+ const extValue = ext(resolve(relativePath, page), extensions);
42
+ if (!extValue) {
43
+ fail(`当前${page}找不到入口.js或.ts文件`);
44
+ process.exit(1);
45
+ }
46
+
47
+ const entryKey = `${root}/${page}${extValue.ext}`;
48
+ entry = entry.concat(
49
+ [{
50
+ key: entryKey,
51
+ filePath: extValue.file,
52
+ type: 'page',
53
+ moduleInfo: {
54
+ path: relativePath,
55
+ root,
56
+ },
57
+ }],
58
+ getComponentEntry(pageJsonContent, pageDir, path.dirname(entryKey), newModules[index]),
59
+ );
60
+ }
61
+ });
62
+ });
63
+ return entry;
64
+ }
65
+
66
+ // 根据pageJson,filePath,获取页面引入的所有component
67
+ function getComponentEntry(pageJson, pagePath, pageKey, moduleInfo) {
68
+ const componentEntry = [];
69
+ function task(json, dir, rootKey) {
70
+ if (!json.usingComponents) {
71
+ return;
72
+ }
73
+
74
+ const componentKeys = Object.keys(json.usingComponents);
75
+
76
+ // 如果存在依赖的组件
77
+ componentKeys.forEach((key) => {
78
+ if (json.usingComponents[key].startsWith('.')) {
79
+ // 拼出组件所在位置的绝对路径
80
+ const comValue = path.join(dir, json.usingComponents[key]);
81
+ const extValue = ext(comValue, extensions);
82
+ const comKey = path.resolve('/', rootKey, json.usingComponents[key]);
83
+ if (!extValue) {
84
+ fail(`当前page: ${pagePath} component: ${comValue}找不到入口.js或.ts文件`);
85
+ process.exit(1);
86
+ }
87
+
88
+ componentEntry.push({
89
+ key: `${comKey.slice(1)}${extValue.ext}`,
90
+ filePath: extValue.file,
91
+ type: 'component',
92
+ moduleInfo: {
93
+ path: moduleInfo.path,
94
+ root: moduleInfo.root,
95
+ },
96
+ });
97
+
98
+ const comJsonPath = `${comValue}.json`;
99
+ if (fs.existsSync(comJsonPath)) {
100
+ const comJsonContent = JSON.parse(fs.readFileSync(comJsonPath, 'utf-8'));
101
+
102
+ const comDir = path.dirname(comJsonPath); // 该页面所在的目录
103
+ task(comJsonContent, comDir, path.dirname(comKey));
104
+ }
105
+ }
106
+ });
107
+ }
108
+
109
+ task(pageJson, pagePath, pageKey);
110
+
111
+ return componentEntry;
112
+ }
113
+
114
+ // 收集依赖在非模块内的目录
115
+ function getDepDirOfNotInModule(modules, tmsConfig, moduleDir) {
116
+ const result = [];
117
+ const pageInfoArr = getPageEntry(modules, tmsConfig, moduleDir);
118
+ // const pageInfoArr = [{
119
+ // type: 'component',
120
+ // filePath: '/Users/odile/workspace/tms-frontend1/miniprogram/modules/home/common/components/favorite/favorite.js',
121
+ // moduleInfo: {
122
+ // root: 'modules/home/welfare',
123
+ // path: '../../miniprogram/modules/home/welfare',
124
+ // },
125
+ // }];
126
+ pageInfoArr.filter(item => item.type === 'component').forEach((item) => {
127
+ const { moduleInfo, filePath } = item;
128
+ // 文件路径 相对于 模块path的路径 ../../common/data
129
+ const moduleFileRelative = path.relative(resolve(moduleInfo.path), filePath);
130
+
131
+ // '../../common/data' => '../../common'
132
+ const fileRelativeDir = moduleFileRelative.match(/^(\.\.\/)+([^/]*)/);
133
+ // eslint-disable-next-line
134
+ if (fileRelativeDir && fileRelativeDir[0]) {
135
+ const fileDir = resolve(moduleInfo.path, fileRelativeDir[0]);
136
+ if (fs.existsSync(fileDir)) {
137
+ result.push({
138
+ from: fileDir,
139
+ to: resolve(tmsConfig.webpack.outputDir, moduleInfo.root, fileRelativeDir[0]),
140
+ });
141
+ }
142
+ }
143
+ });
144
+
145
+ return unique(result, 'from');
146
+ }
147
+
148
+ module.exports = {
149
+ getDepDirOfNotInModule,
150
+ };
@@ -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,9 @@ 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
+ console.log('>>>>>>>>>>>>', subRoot);
113
115
  const toppath = path.join(cwd, subRoot.root); // 从该目录开始查找package.json文件
114
116
  const list = findFilesByFilter(toppath, packageJsonName);
115
117
 
@@ -119,8 +121,25 @@ const findAllPackageJson = (subRoots = [], contextDir) => {
119
121
  return result;
120
122
  };
121
123
 
124
+ function cloudNpmInstall(contextDir) {
125
+ return new Promise((resolve, reject) => {
126
+ glob(`${contextDir}/**/package.json`, ['node_modules', 'miniprogram_npm'], (err, files) => {
127
+ if (err) {
128
+ reject(err);
129
+ }
130
+ files.forEach((file) => {
131
+ const dir = path.dirname(file);
132
+ shell.cd(dir);
133
+ shell.exec('npx npm install --production --registry http://mirrors.tencent.com/npm/', { silent: false });
134
+ });
135
+ resolve();
136
+ });
137
+ });
138
+ }
139
+
122
140
 
123
141
  module.exports = {
124
- npmInstallAll,
142
+ cloudNpmInstall,
143
+ mpNpmInstallAll,
125
144
  findAllPackageJson,
126
145
  };
@@ -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;