Giter Club home page Giter Club logo

webpack-demo's Introduction

webpack-demo

single—-entry

webpack单入口打包初体验。看文档说,treeShaking好像需要搭配代码压缩插件才能生效。

babel

在webpack打包基础上加入babel。

babel 7采用@babel/preset-env的preset,可以根据targets中设定的浏览器,自动的依据浏览器的支持情况,按需引入需要的包来对e6以前的代码进行转换。此举可以减少引入不必要的polyfill

当 useBuiltIns 设置为 usage 时,Babel 会在你使用到 ES2015+ 新特性时,自动添加 babel-polyfill 的引用,并且是 partial 级别的引用。 当 useBuiltIns 设置为 entry 时,根据配置的浏览器兼容,引入浏览器不兼容的 polyfill。需要在入口文件手动添加 import 'core-js';,会自动根据 browserslist 替换成浏览器不兼容的所有 polyfill。

总结一下就是:targets来限定需要兼容的浏览器版本,以此来确定哪些polyfill是当前浏览器需要的。在通过useBuiltIns来决定polyfill的引入方式。usage是用了啥不兼容的语法引入啥,entry是根据浏览器配置,引入所有所有当前浏览器不兼容的polyfill;

webpack-demo's People

Contributors

johngong999 avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.