| 1234567891011121314151617181920212223242526272829303132 |
- const fs = require('fs');
- const path = require('path');
- const { compile } = require('@vue/compiler-sfc');
- // 读取 Vue 文件
- const vueFileContent = fs.readFileSync(path.resolve(__dirname, 'src/views/front/ProjectCases.vue'), 'utf8');
- try {
- // 编译 SFC 文件
- const result = compile(vueFileContent);
-
- if (result.errors.length > 0) {
- console.error('Vue 模板编译错误:');
- result.errors.forEach(error => {
- console.error(`错误在 ${error.loc.start.line}:${error.loc.start.column} - ${error.message}`);
- });
- }
-
- if (result.warnings.length > 0) {
- console.warn('Vue 模板编译警告:');
- result.warnings.forEach(warning => {
- console.warn(`警告在 ${warning.loc.start.line}:${warning.loc.start.column} - ${warning.message}`);
- });
- }
-
- if (result.errors.length === 0) {
- console.log('Vue 模板编译成功');
- }
- } catch (error) {
- console.error('Vue 模板编译失败:', error);
- }
|