去掉打印 和 Web的样式手动import
This commit is contained in:
parent
beb6f0c22c
commit
eae48b17e3
|
|
@ -14,42 +14,42 @@ function isOakNamespaceIdentifier(node, name) {
|
|||
module.exports = (babel) => {
|
||||
return {
|
||||
visitor: {
|
||||
Program(path, state) {
|
||||
const { cwd, filename } = state;
|
||||
const rel = relative(cwd, filename).replace(/\\/g, '/');
|
||||
if (
|
||||
/(pages|components)[\w|\W]+(index\.tsx|index\.pc\.tsx)$/.test(
|
||||
rel
|
||||
)
|
||||
) {
|
||||
const lessFile = filename.replace(/\.(ts|tsx)$/, '.less');
|
||||
const lessFileExists = fs.existsSync(lessFile);
|
||||
const pcLessFile = filename.replace(
|
||||
/\.(ts|tsx)$/,
|
||||
'.pc.less'
|
||||
);
|
||||
const pcLessFileExists = fs.existsSync(pcLessFile);
|
||||
const { body } = path.node;
|
||||
const lessFileImport = rel.endsWith('.pc.tsx')
|
||||
? pcLessFileExists
|
||||
? './index.pc.less'
|
||||
: './index.less'
|
||||
: lessFileExists
|
||||
? './index.less'
|
||||
: './index.pc.less';
|
||||
if (
|
||||
(lessFileExists && !pcLessFileExists) ||
|
||||
(!lessFileExists && pcLessFileExists)
|
||||
) {
|
||||
body.unshift(
|
||||
t.importDeclaration(
|
||||
[],
|
||||
t.stringLiteral(lessFileImport)
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
},
|
||||
// Program(path, state) {
|
||||
// const { cwd, filename } = state;
|
||||
// const rel = relative(cwd, filename).replace(/\\/g, '/');
|
||||
// if (
|
||||
// /(pages|components)[\w|\W]+(index\.tsx|index\.pc\.tsx|web\.tsx|web\.pc\.tsx|web\.jsx|web\.pc\.jsx)$/.test(
|
||||
// rel
|
||||
// )
|
||||
// ) {
|
||||
// const lessFile = filename.replace(/\.(ts|tsx|jsx)$/, '.less');
|
||||
// const lessFileExists = fs.existsSync(lessFile);
|
||||
// const pcLessFile = filename.replace(
|
||||
// /\.(ts|tsx)$/,
|
||||
// '.pc.less'
|
||||
// );
|
||||
// const pcLessFileExists = fs.existsSync(pcLessFile);
|
||||
// const { body } = path.node;
|
||||
// const lessFileImport = rel.endsWith('.pc.tsx')
|
||||
// ? pcLessFileExists
|
||||
// ? './index.pc.less'
|
||||
// : './index.less'
|
||||
// : lessFileExists
|
||||
// ? './index.less'
|
||||
// : './index.pc.less';
|
||||
// if (
|
||||
// (lessFileExists && !pcLessFileExists) ||
|
||||
// (!lessFileExists && pcLessFileExists)
|
||||
// ) {
|
||||
// body.unshift(
|
||||
// t.importDeclaration(
|
||||
// [],
|
||||
// t.stringLiteral(lessFileImport)
|
||||
// )
|
||||
// );
|
||||
// }
|
||||
// }
|
||||
// },
|
||||
JSXAttribute(path, state) {
|
||||
const { cwd, filename } = state;
|
||||
const rel = relative(cwd, filename).replace(/\\/g, '/');
|
||||
|
|
|
|||
|
|
@ -14,7 +14,6 @@ module.exports = (babel) => {
|
|||
const jsPage = (/oak-general-business\/lib/.test(rel) && /(pages|components)[\w|\W]+index\.(web.js|js)$/.test(rel)) ||
|
||||
(!/node_modules/.test(rel) && /(pages|components)[\w|\W]+index\.(web.js|js)$/.test(rel));
|
||||
if (tsPage || jsPage) {
|
||||
console.log(rel);
|
||||
const tsxFile = filename.replace(
|
||||
/index\.(web.ts|ts|web.js|js)$/,
|
||||
tsPage ? 'web.tsx' : 'web.jsx'
|
||||
|
|
|
|||
Loading…
Reference in New Issue