[英]Babel only compiles js files of my Vue project, not the entire project
I have a Vue project that that I want to use on old iPad, running iOS/safari version 5. This means I need to transpile it to ES5 using Babel.我有一个 Vue 项目,我想在旧 iPad 上使用它,运行 iOS/safari 版本 5。这意味着我需要使用 Babel 将其转换为 ES5。
This is what my babel.config.js
looks like这就是我的
babel.config.js
样子
presets: [
//'@vue/cli-plugin-babel/preset',
["@babel/env",
{
targets: {
safari: "5",
ios: "5",
},
useBuiltIns: "usage",
"corejs": "3.6.4",
},]
]
}
Now when I run npx babel src --out-dir dist
, babel only compiles the .js
files to the dist
folder.现在,当我运行
npx babel src --out-dir dist
,babel 只将.js
文件编译到dist
文件夹。 No .vue
files, static assets and html
files are compiled/copied to the dist
folder.没有
.vue
文件、静态资产和html
文件被编译/复制到dist
文件夹。
How can I get Babel to compile not just the .js
files, and is there anything else I need to do to transpile my project to ES5?如何让 Babel 不仅编译
.js
文件,还有什么我需要做的事情才能将我的项目转换为 ES5?
This is my package.json
:这是我的
package.json
:
{
"name": "frontend",
"version": "0.1.0",
"private": true,
"scripts": {
"serve": "vue-cli-service serve",
"build": "vue-cli-service build",
"lint": "vue-cli-service lint"
},
"dependencies": {
"@babel/polyfill": "^7.12.1",
"axios": "^0.20.0",
"core-js": "^3.6.5",
"sass": "^1.27.0",
"sass-loader": "^10.0.3",
"vue": "^2.6.11",
"vue-axios": "^2.1.5",
"vue-device-detector": "^1.1.6",
"vue-material": "^1.0.0-beta-15",
"vue-router": "^3.2.0",
"vuelidate": "^0.7.5"
},
"devDependencies": {
"@babel/cli": "^7.12.1",
"@babel/core": "^7.12.3",
"@babel/preset-env": "^7.12.1",
"@vue/cli-plugin-babel": "~4.5.0",
"@vue/cli-plugin-eslint": "~4.5.0",
"@vue/cli-plugin-router": "~4.5.0",
"@vue/cli-service": "~4.5.0",
"babel-eslint": "^10.1.0",
"eslint": "^6.7.2",
"eslint-plugin-vue": "^6.2.2",
"vue-template-compiler": "^2.6.11"
}
}
这不是 babel 编译静态资产的目的,为此您需要像 webpack 这样的打包器或像 Gulp 这样的任务运行器。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.