mirror of
https://github.com/youzan/vant.git
synced 2025-10-20 02:31:21 +00:00
[build] remove @vant/compiler (#2671)
This commit is contained in:
@@ -4,22 +4,18 @@
|
||||
const fs = require('fs-extra');
|
||||
const path = require('path');
|
||||
const babel = require('@babel/core');
|
||||
const compiler = require('@vant/compiler');
|
||||
const markdownVetur = require('markdown-vetur');
|
||||
|
||||
const esDir = path.join(__dirname, '../es');
|
||||
const libDir = path.join(__dirname, '../lib');
|
||||
const srcDir = path.join(__dirname, '../packages');
|
||||
const veturDir = path.join(__dirname, '../vetur');
|
||||
const compilerOption = {
|
||||
babel: {
|
||||
configFile: path.join(__dirname, '../babel.config.js')
|
||||
}
|
||||
const babelConfig = {
|
||||
configFile: path.join(__dirname, '../babel.config.js')
|
||||
};
|
||||
|
||||
const isDir = dir => fs.lstatSync(dir).isDirectory();
|
||||
const isJs = path => /\.js$/.test(path);
|
||||
const isSfc = path => /\.vue$/.test(path);
|
||||
const isCode = path => !/(demo|test|\.md)$/.test(path);
|
||||
|
||||
function compile(dir) {
|
||||
@@ -38,21 +34,9 @@ function compile(dir) {
|
||||
return compile(filePath);
|
||||
}
|
||||
|
||||
// compile sfc
|
||||
if (isSfc(file)) {
|
||||
const source = fs.readFileSync(filePath, 'utf-8');
|
||||
fs.removeSync(filePath);
|
||||
|
||||
const jsPath = filePath.replace('.vue', '.js');
|
||||
const vuePath = filePath + '.js';
|
||||
const output = fs.existsSync(jsPath) ? vuePath : jsPath;
|
||||
|
||||
return fs.outputFileSync(output, compiler(source, compilerOption).js);
|
||||
}
|
||||
|
||||
// compile js
|
||||
if (isJs(file)) {
|
||||
const { code } = babel.transformFileSync(filePath, compilerOption.babel);
|
||||
const { code } = babel.transformFileSync(filePath, babelConfig);
|
||||
fs.outputFileSync(filePath, code);
|
||||
}
|
||||
});
|
||||
|
Reference in New Issue
Block a user