简体   繁体   English

Babel 只编译我的 Vue 项目的 js 文件,而不是整个项目

[英]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.

相关问题 Babel JS-安装项目 - Babel JS - setup project 构建js文件vue cli项目 - Structuring js files vue cli project Babel 和 next.js - 如何在项目中构建、babel 和附加我自己的脚本 - Babel and next.js - how build, babel and attach my own script in project 运行“npm start”会无休止地编译我的项目 - running 'npm start' compiles my project endlessly 带引导程序的 VUE js 模态不适用于我的 vue 项目 - VUE js modal with bootstrap is not working with my vue project 整理整个项目(相对于.css,.js,.html文件) - Uglify entire project (.css, .js, .html files relatively) vue.js: `vue create` 在项目文件夹中只创建 3 个文件(package.json、package-lock.json、README.md) - vue.js: `vue create` creates only 3 files in project folder (package.json, package-lock.json, README.md) 将js导入Vue项目 - Importing js to Vue project 只能生成js文件(位于dist文件夹中),而不能生成项目目录中的其他文件(如html,css ..)。 我正在使用“ build”:“ babel source -d dist” - Bable in only producing js files(in dist folder) and not other files in project directory(like html,css..). I am using “build”:“babel source -d dist” 我不能在我的 vue.js 项目中使用类型化的 js - I can't use typed js in my vue js project
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM