Giter Club home page Giter Club logo

wxmini-plugin-webpack's Introduction

wxmini-plugin-webpack

webpack5版本的微信小程序插件,让微信原生小程序的开发也能变成工程化。

使用

npm -i -D wxmini-plugin-webpack

js-template 案例

ts-template 案例

优势/好处

  • 1.可以区分不同的环境变量,dev, production开发环境等等

  • 2.无用代码筛检,剔除

  • 3.@importrequire<wxs src'@src/test.wxs'></wxs>, json文件的组件引入 可以用别名引入,如@src, @common等

  • 4.代码体积小,不会像uniapp, Taro,产生大量运行代码

  • 5.支持ts,支持es6语法的import export deufalt

注意事项

  • 子的.less的文件如果引入在父页面的less中,会合并到一个文件,.wxss文件后缀用@import引入的文件,不会合并一个文件

  • 只有两个公共js文件,runtime.jscommon.js

生产模式输出文件信息

图片

webpack配置

// webpack配置

const  MiniProgramPlugin  = require('wxmini-plugin-webpack').plugin

module.exports = {
    ...,
    ...,
    module: {
      rules: [
        {
          test: /\.wxml$/,
          type: 'asset/resource',
          generator: {
            filename: '[path][name][ext]'
          },
          use: [
            'wxmini-plugin-webpack'
          ]
        },
        {
          test: /\.json/,
          type: 'asset/resource',
          generator: {
            filename: '[path][name][ext]'
          },
          use: [
            'wxmini-plugin-webpack'
          ]
        },
        {
          test: /\.wxs$/,
          type: 'asset/resource',
          generator: {
            filename: '[path][name][ext]'
          },
          use: ['wxmini-plugin-webpack']
        },
        {
          test: /\.wxss/,
          type: 'asset/resource',
          generator: {
            filename: '[path][name][ext]'
          },
          use: ['wxmini-plugin-webpack']
        },
        ...,
        ...,
        ...
      ]
      },
    plugins: [
        new MiniProgramPlugin()
    ],
    ...,
    ...,
    ...
}

To-do

代办事项

  • wxss文件代码压缩
  • 输出打包文件信息
  • 显示打包进度

本地调试

安装依赖
npm i

// 运行脚本
node example/build-examples.js resolve-template
或者
npm run dev
npm run build
npm源切换

npm config get registry

npm config set registry https://registry.npmjs.org/

npm config set registry https://registry.npmmirror.com

qq讨论群: 475870039

wxmini-plugin-webpack's People

Contributors

wangzhenhao avatar

Stargazers

Infinity avatar eric avatar  avatar

Watchers

hotsuitor 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.