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

vue-chunk-routes-store

v1.0.1

Published

+ 路由的路径为`~/routes`,在webpack的alias别称中添加了`~`来代替`src`,`~/routes`即是`src`下的`routes`文件夹。

Downloads

6

Readme

因为webpack的require.context的第一个参数只支持字面量,无法使用变量,所以本项目的路径是写死的,具体路径可以在注册时修改,或者在webpack的alias配置中添加别称。

  • 路由的路径为~/routes,在webpack的alias别称中添加了~来代替src~/routes即是src下的routes文件夹。

  • 同理~/store/modules即为src/store/modules文件夹。

使用了这个插件后。

不需要在routes/index.js中写routes,会自动检索src/routes/modules下的所有除了index.js的js文件,自动注册到路由中。

不需要在store/index.js中写入modules,会自动检索src/store/modules下所有的js文件,自动注册到store中。

使用方法


import store from '~/store'
import router from '~/routes'

import autoRouteStore from './index'
const routerContext = require.context('~/routes/modules', true, /\.js$/)
const storeContext = require.context('~/store/modules', true, /\.js$/)
Vue.use(autoRouteStore, {
  router,
  routerContext,
  storeContext,
  store
})

注意事项

因webpack在dev下的缓存配置问题,当删除目录下的文件夹时,需要npm run dev重新启动项目来更新缓存

目录

|__src
  |__routes
    |__modules
      |__demo1-router.js
      |__demo2-router.js
    |__index.js
  |__store
    |__modules
      |__demo1-store.js
      |__demo2-store.js
    |__global.js
    |__index.js

routes/index.js

import Vue from 'vue'   // 引入vue
import VueRouter from 'vue-router'   // 引入vue-router

const router = new VueRouter({
  routes: []
})

Vue.use(VueRouter)

export default router

store/index.js

import Vue from 'vue'
import Vuex from 'vuex'

import global from '~/store/global'
Vue.use(Vuex)

const store = new Vuex.Store({
  modules: {
    global
  }
})

export default store