支持web.ts
This commit is contained in:
parent
6309f3a98d
commit
741b6b8484
|
|
@ -10,10 +10,10 @@ module.exports = (babel) => {
|
||||||
Program(path, state) {
|
Program(path, state) {
|
||||||
const { cwd, filename } = state;
|
const { cwd, filename } = state;
|
||||||
const rel = relative(cwd, filename).replace(/\\/g, '/');
|
const rel = relative(cwd, filename).replace(/\\/g, '/');
|
||||||
if (/pages|components[\w|\W]+index\.ts$/.test(rel)) {
|
if (/pages|components[\w|\W]+index\.(web.ts|ts)$/.test(rel)) {
|
||||||
const tsxFile = filename.replace(/\.ts$/, '.tsx');
|
const tsxFile = filename.replace(/\.(web.ts|ts)$/, '.tsx');
|
||||||
const tsxFileExists = fs.existsSync(tsxFile);
|
const tsxFileExists = fs.existsSync(tsxFile);
|
||||||
const pcTsxFile = filename.replace(/\.ts$/, '.pc.tsx');
|
const pcTsxFile = filename.replace(/\.(web.ts|ts)$/, '.pc.tsx');
|
||||||
const pcTsxFileExists = fs.existsSync(pcTsxFile);
|
const pcTsxFileExists = fs.existsSync(pcTsxFile);
|
||||||
/** 根据tsx文件存在的情况,注入如下的render代码
|
/** 根据tsx文件存在的情况,注入如下的render代码
|
||||||
* if (true) {
|
* if (true) {
|
||||||
|
|
@ -21,7 +21,7 @@ module.exports = (babel) => {
|
||||||
return renderMobile.call(this);
|
return renderMobile.call(this);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
const renderScreen = require('./index.screen.tsx').default;
|
const renderScreen = require('./index.pc.tsx').default;
|
||||||
return renderScreen.call(this);
|
return renderScreen.call(this);
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
@ -95,7 +95,7 @@ module.exports = (babel) => {
|
||||||
} else {
|
} else {
|
||||||
assert(
|
assert(
|
||||||
false,
|
false,
|
||||||
`${filename}文件夹中不存在index.tsx或者index.pc.tsx`
|
`${filename}文件中不存在index.tsx或者index.pc.tsx`
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
const node = path.node;
|
const node = path.node;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue