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

mpvue-entry-with-subpackage

v1.4.7-alpha

Published

集中式页面配置,自动生成各页面的入口文件,优化目录结构,支持新增页面热更新

Downloads

7

Readme

mpvue-entry

集中式页面配置,自动生成各页面的入口文件,优化目录结构,支持新增页面热更新

npm package npm downloads build status codecov codebeat badge license

目录结构

├─build
├─config
├─src
│ ├─components
│ ├─pages
│ │  └─news
│ │     │─list.vue
│ │     └─detail.vue
│ ├─App.vue
│ ├─main.js
│ └─pages.js
└─package.json

原理

src/main.js 为模板,使用配置文件中的 pathconfig 属性分别替换 vue 文件导入路径导出信息

Quickstart

https://github.com/F-loat/mpvue-quickstart

vue init F-loat/mpvue-quickstart my-project

安装

npm i mpvue-entry -D

使用

// webpack.base.conf.js
const MpvueEntry = require('mpvue-entry')

module.exports = {
  entry: MpvueEntry.getEntry('src/pages.js'),
  ...
  plugins: [
    new MpvueEntry(),
    ...
  ]
}
// pages.js
module.exports = [
  {
    path: 'pages/news/list', // 页面路径,同时是 vue 文件相对于 src 的路径,必填
    config: { // 页面配置,即 page.json 的内容,可选
      navigationBarTitleText: '文章列表',
      enablePullDownRefresh: true
    }
  }
]

参数

MpvueEntry.getEntry(paths)
  • paths String/Object

paths 为 String 类型时作为 pages 的值,自定义值为绝对路径或相对于项目根目录的相对路径(这里的相对路径实际上是相对于被执行文件的上级目录的)

// 默认值
{
  // 页面配置文件
  pages: 'src/pages.js',
  // 主入口文件,作为模板
  main: 'src/main.js',
  // 入口模板文件,优先级较高
  template: undefined,
  // 项目配置文件
  app: 'dist/app.json',
  // 各页面入口文件目录
  entry: 'mpvue-entry/dist/'
}

// 示例
MpvueEntry.getEntry({
  pages: 'src/router/index.js',
  app: 'wxapp/app.json',
})

Tips

  • 首页默认为 pages.js 中的第一项,但会被 main.js 中的配置覆盖

  • path 属性兼容绝对路径,且仅指定 path 属性时可简写为字符串形式

// pages.js
module.exports = [
  '/pages/news/list',
  '/pages/news/detail'
]
  • 可通过以下形式的注释指定 main.js 特有代码
console.log('hello world') // app-only

/* app-only-begin */
console.log('happy')
console.log('coding')
/* app-only-end */
  • 可通过 native 属性指定页面为原生开发,不做编译处理
// pages.js
module.exports = [
  {
    path: 'pages/news/list',
    native: true
  }
]
  • 可通过 subPackage 属性指定页面需分包加载(配合 Quickstart 模板使用效果更佳)
// pages.js
module.exports = [
  {
    path: 'packageA/news/detail',
    subPackage: true
  }
]
  • 可通过 root 属性指定分包根路径,指定后 subPackage 属性会自动置为 true
// pages.js
module.exports = [
  {
    path: 'pages/news/detail',
    root: 'pages/news'
  }
]

示例

[email protected] 为界(其实用法是一样的)

Thanks