Giter Club home page Giter Club logo

megalo-analyze's Introduction

megalo 构建过程分析

关于webpack 配置解释

用到的工具:

  • @megalo/target => 构建目标
  • @megalo/template-compiler => 模板编译器
  • @megalo/env-plugin => 注入环境变量 process.env.PLATFORM 和 process.env.NODE_ENV
  • vue-loader => 加载和解析 .vue 文件
  • mini-css-extract-plugin => 将 css 提取到 .wxss 文件

@megalo/target

提供 createMegaloTarget 方法,接收

  • compiler 模板编译器
  • platform 指定小程序平台
  • htmlParse v-html 模板解析工具

内部实现

应用了以下插件

  • LoaderTargetPlugin => webpack.LoaderTargetPlugin
  • MegaloPlugin => @megalo/target/lib/plugins/MegaloPlugin
  • frameworks/vue/plugin => @megalo/target/lib/frameworks/vue/plugin
  • frameworks/regular/plugin => @megalo/target/lib/frameworks/regular/plugin

LoaderTargetPlugin

在载入每个模块时候设置上下文target值

MegaloPlugin

需要 createMegaloTarget 接收的参数作为参数传入

生成平台代码文件

      // emit files, includes:
      // 1. pages (wxml/wxss/js/json)
      // 2. components
      // 3. slots
      // 4. htmlparse

hookJSEntry

处理入口文件

@megalo/target/lib/loaders/js-entry

在babel-loader处理之前进行处理

vue-loader

将其他规则应用到.vue文件中对应的语言模块

解释和用法:手动配置

peer dependency -> vue-template-compiler

MegaloPlugin

megalo-analyze's People

Contributors

qubitsky avatar

Watchers

 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.