Giter VIP home page Giter VIP logo

tiny-webpack's Introduction

my-mini-webpack

一个简略版的webpack,其大致思路也很简单:首先通过入口文件收集依赖->遍历依赖生成图->通过图打包并生成文件; 其核心文件是根目录下的index.js ,里面模拟实现了loaderplugin ;

loader

其实就是一个转换器,因为webpack只认识js文件,那么要想对其他文件页进行打包,就需要使用loader 将不同类型的文件转换成js 文件; 一个loader 就是一个函数,输入的是源文件,输出js文件/(中间文件以便后续loader 进行处理);

plugin

webpack在打包的过程中会触发一些事件,而插件会监听这些事件,当监听到的时候就会触发相应的函数,这也就是常说的发布-订阅者模式,那么在写自己的插件的时候会使用到tapable库,其提供了很多发布订阅模式的API,比如SyncHookSyncBailHook等,每一个插件内部都有一个apply方法,在其内部进行事件的监听;

使用说明

安装依赖

 npm install

运行

 node index.js

tiny-webpack's People

Contributors

doit008 avatar

Stargazers

 avatar

Watchers

 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.