npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

webpack-miniapp-plugin

v0.0.6

Published

A webpack plugin for Tencent mini-program development. Let's use webpack as we known.

Downloads

2

Readme

webpack-miniapp-plugin

  • 修正 tabBar 解析的bug

安装说明

npm install webpack-miniapp-plugin
// or
yarn add webpack-miniapp-plugin

使用示例

具体参考 test/webpack.config.js 文件。

module.exports = {
 output: {
  libraryTarget: 'var', // 必须
 },
 target: 'node', // 必须
 plugins: [
  new miniappPlugin(src, dist, options),
 ]
};

options 的参考:

const options = {
 main:                'app.json',
 mockMain:            'app.my.json', // 创建一个模拟入口
    debug:               false,
    assets:              'assets',
    assetsChunkName:     '__assets_chunk_name__',
    bootstrapModuleName: 'bootstrap.js',
    // 公共附件后缀名,以 object 结构,如果要去掉某类文件,value 取 false
    exts:                {
        json: true,
        wxml: true,
        wxss: false,
    },
    // 脚本后缀名
    scriptExts:          {js: true},
    // 需要检查 io stat 的文件后缀,wxss 不是必选项,可能存在 page 或者 component 没有 wxss 文件
    checkStatExts:       {wxss: true},
    // app.js - app.json 的特定附加文件。
    app:                 {
        exts:  {wxml: false},
        // 附加文件
        files: [ // 不附加文件的话,files: false
            'sitemap.json', 'project.config.json',
        ],
    },
    // page 范围内的设定
    page:                {
  // 使用公共的后缀文件名
        // exts: {wxml: true},
        files: [],
    },
    // component 范围内的设定
    component:           {
        // exts: {wxml: true},
        files: [],
    },
    // 自定义路径匹配指定附加文件
    custom:              {
  // 指定 pages/index/index 的附加设定
        'pages/index/index': {
          files: ['ok.json'],
        },
    },
}

引入依赖的路径写法

开发中引入 js 的路径,请严格遵照 npm 的标准,当前目录下的文件,应该是 require('./mobx') 或者 require('./any-module')require('loadsh') 表示引入 node_modules 下的 module。否则会导致 webpack 编译处理 js 的依赖关系时报错。

component 支持绝对路径和相对路径的两种写法:../../components/hello/world/components/hello/world

已经支持检索 app.json 中的 pages, subPackages, tabBar ,以及各个 json 中定义的 useComponents 字段。

样式文件

通过JS引入的模式(推荐)

样式文件,推荐在对应的 js 文件中引入(require 或 import),这样的好处是,可以使用 mini-css-extract-pluginextract-css-chunks-webpack-plugin ,来打包分离成对应的 wxss 文件,最终输出的效果更好。

loaders 可以参照如下的配置:

module.exports = {
 module: {
  rules: [
   {
        test: /\.styl$/,
        use:  [MiniCssExtractPlugin.loader, 'css-loader', 'stylus-loader'],
    },
    {
        test: /\.(css|wxss)$/,
        use:  [MiniCssExtractPlugin.loader, 'css-loader'],
    },
  ]
 }
}

复制wxss模式

如果你希望插件对待 wxss 文件时,作为附加文件的模式处理的话,也是可以的,需要做如下的设置:

const path = require('path');

module.exports = {
 module: {
  rules: [
    {
        test: /\.(wxss)$/,
        use:  {
            loader: 'file-loader',
            options: {
            name: (filename) => replaceDS(path.relative(srcPath, filename)), // 文件名路径名转换
            },
        },
    },
  ]
 },
 plugins: [
        new miniappPlugin(src, dist, {
         exts: {
          wxss: true, // 开启 wxss 作为附件打包
         }
        }),
    ]
};