babel

babel知识点

匿名 (未验证) 提交于 2019-12-02 23:40:02
版权声明:如果您对这个文章有任何异议,那么请在文章评论处写上你的评论。 如果您觉得这个文章有意思,那么请分享并转发,或者也可以关注一下表示您对我们文章的认可与鼓励。 愿大家都能在编程这条路,越走越远。 https://blog.csdn.net/weixin_44369568/article/details/91458533 Babel 1、Babel 是javascript的编译器/解码器/转码器/解析器 2、配置 .babelrc 命令: babel ./index.js -o ./_index.js 下包: cnpm install --save-dev babel-cli babel-preset-env { "presets": [ "env" ] } babel-loader // es6转es5 文章来源: https://blog.csdn.net/weixin_44369568/article/details/91458533

安装babel遇到的异常

匿名 (未验证) 提交于 2019-12-02 23:05:13
Error: Requires Babel "^7.0.0-0", but was loaded with "6.26.3". If you are sure you have a compatible version of @babel/core, it is likely that something in your build process is loading the wrong version. Inspect the stack trace of this error to look for the first entry that doesn't mention "@babel/core" or "babel-core" to see what is calling Babel. @babel/cli 中包含了 @babel/node ,但是版本比较低。最好重新安装一遍 @babel/node npm install -g @babel/node

webpack4.0搭建vue教程

匿名 (未验证) 提交于 2019-12-02 23:03:14
参考链接 没有安装记得先安装webpack npm install webpack webpack-cli -D 老版本的打包方案是: webpack .\src\main.js .\dist\bundle.js 而在webpack4之后 官方对 webpack-cli 单独抽离了出来 所以打包语句就变了 npx webpack a.js --output-filename b.js --output-path . --mode development mode 表示生产还是开发模式 添加 mode: 'production' 在webpack.config.js 中(如果没有这个文件就自己创建一下了) 在根目录下新建文件 webpack.config.js 参考链接 module.exports = { // 打包文件入口 entry // 1. 单一条目语法可以简写 // 2. 传递数组(将多个依赖文件一起注入并将其依赖关系映射到一个“块”) // 3. 对象(“可扩展的webpack配置”是可以重用并与其他部分配置组合的配置) entry: path.join(__dirname,'./src/main.js'), output:{// 输出文件相关配置 path: path.join(__dirname,'./dist'), filename:'bundle.js' },

babel7-按需加载polyfill

匿名 (未验证) 提交于 2019-12-02 23:03:14
babel7 babel7发布了。 在升级到 Babel 7 时需要注意几个重大变化: 移除对 Node.js 6 之前版本的支持; 使用带有作用域的 @babel 命名空间,以防止与官方 Babel 包混淆; 移除年度预设,替换为 @babel/preset-env; 使用选择性 TC39 个别提案替换阶段提案; TC39 提议插件现在是 -proposal,而不是 -transform; 为某些面向用户的包(例如 babel-loader、@babel/cli 等)在 @babel/core 中引入peerDependency。 官方提供了一个工具babel-upgrade,对于老项目,只需要执行: npx babel-upgrade --write --install 具体看https://github.com/babel/babel-upgrade useBuiltIns:usage babel的polyfill总是比较大,会影响一些性能,而且也会有一些没用的polyfill,怎么减少polyfill的大小呢? babel7提供了useBuiltIns的按需加载:usage。 配置中设置useBuiltIns:usage,babel就会自动把所需的polyfill加载进来,不需要手动import polyfill文件。 配置如: { "presets": [ "@babel

webpack配置antd的按需加载

匿名 (未验证) 提交于 2019-12-02 22:56:40
安装 babel-plugin-import 插件。下面方法二选一,都可以。 一、配置webpack.config.js文件 { test: /.jsx?$/ , exclude: /(node_modules|bower_components)/ , use: [{ loader: ‘babel-loader‘ }], options: { "plugins" : [ [ "import" , { "libraryName": "antd" , "style": true } ] ] } } 二、配置babelrc文件 { "presets": ["env", "react" ], "plugins" : [ "transform-runtime" , "transform-object-rest-spread" , [ "import" , { "libraryName": "antd" , "style": true } ] ] } 原文:https://www.cnblogs.com/camille666/p/webpack_antd.html

Syntax error in IE11 with Webpack, Babel and React

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-02 22:41:19
I'm getting a Syntax Error in my React + Redux project in Internet Explorer 11, but I have no idea why it's caused. I'm using Webpack and Babel to compile it. I tried using babel-polyfill and babel-es6-polyfill, but that didn't help. This is the error I'm getting: SCRIPT1002: Syntax error File: app.js, Line: 70, Column: 1 Line 70 Column 1 is where the eval starts of Webpack: /***/ }), /* 21 */, /* 22 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; eval("\n\nObject.define... <- Line 70 ^--- Column 1 This is my webpack.config.js : 'use strict'; // Include modules and

在vue中如何安装使用Vant

廉价感情. 提交于 2019-12-02 22:17:26
---恢复内容开始--- Vant中文文档地址:https://youzan.github.io/vant-weapp 1、创建Vue项目之后,运行安装命令 :13:47:04 npm i vant -S 2、 安装babel-plugin-import npm i babel - plugin - import - D 3 来源: https://www.cnblogs.com/qians/p/11764431.html

webpack4 babel ƪ

匿名 (未验证) 提交于 2019-12-02 21:53:52
demo 代码点此 ,如果对 babel 不熟,可以看一下 babel 7 简单指北 。 webpack 使用 babel 来打包使用 es6 及以上语法的 js 文件是非常方便的,可以通过配置,将 es6 转化为 es5. start 准备个空文件,执行如下命令: npm init -y npm i -D webpack webpack-cli npm i -D babel-loader @babel/core 然后创建一个 dist 文件夹,创建一个 html 文件: <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta http-equiv="X-UA-Compatible" content="ie=edge"> <title>webpack4 babel ƪ</title> <body> <div id="root"></div> <script type="text/javascript" src="bundle.js"></script></body> </html> 根目录下创建 webpack.config.js,配置 webpack:

React搭建项目(全家桶)

匿名 (未验证) 提交于 2019-12-02 21:53:52
安装React脚手架: npm install -g create-react-app 创建项目: create-react-app app app:为该项目名称 启动项目: cd appnpm start 项目创建完成,目录如下: 安装 Ant Design: npm install antd --save 或cnpm install antd --save cnpm i antd -S 没有权限请使用 sudo 配置 Ant Design 按需加载: babel-plugin-import (推荐)。 首先暴露配置文件: npm run eject NOTE: Create React App 2+ supports TypeScript, Sass, CSS Modules and more without ejecting: https://reactjs.org/blog/2018/10/01/create-react-app-v2.html 该操作为永久性,不可逆的。 在 package.json 中配置 babel ( ) Error : Cannot find module 'babel-plugin-import' babel-plugin-import npm install babel-plugin-import --save-dev 或 cnpm