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-mixins-loader

v1.0.2

Published

类似 Vue.mixin 功能的 loader

Downloads

3

Readme

vue-mixins-loader

类似 Vue.mixin 功能的 loader,在 Vue 组件打包时,注入一些公共的配置。

如何你对这个 Loader 如何实现很感兴趣,可以戳这里 👉 我的博客·Gitee / 我的博客·GitHub

安装

npm install vue-mixins-loader -save-dev

配置

  • 以路径的方式引入:需要以绝对路径的方式引入,或者以别名的方式引入。
options: {
  // 绝对路径,使用 path.resolve 转为绝对路径
  mixin1: path.resolve('./src/utils/mixin1.js'),
  // 别名,@ 指向 ./src
  mixin2: '@/utils/mixin2.js',
}
  • 使用自定义 mixin 对象,配置在 custom 属性中。由于 loaderoptionswebpack 内部处理时,会转为 JSON 格式,为确保配置能生效,需要使用 vue-mixins-loader 提供的 stringify 方法将其转为一个字符串类型。
options: {
  custom: stringify({
    props: {
      block: {
        type: Object,
        default: () => ({})
      }
    },
    mounted() {
      console.log("this is custom mixins's mounted");
    }
  });
}

使用

webpack.config.js 中配置,需要写在 vue-loader 之后,也即要先于 vue-loader 处理。

const path = require('path');
const { stringify } = require('vue-mixins-loader');

// webpack.config.js
module.exports = {
  module: {
    rules: [
      {
        test: /\.vue$/,
        use: [
          'vue-loader',
          {
            loader: 'vue-mixins-loader',
            options: {
              tools: path.resolve('./src/utils/tools.js'),
              tools2: path.resolve('./src/utils/tools2.js'),
              tools3: '@/utils/tools3.js',
              custom: stringify({
                props: {
                  block: {
                    type: Object,
                    default: () => ({})
                  }
                },
                mounted() {
                  console.log("this is custom mixins's mounted");
                }
              })
            }
          }
        ]
      }
    ]
  }
};

Tip:如果对 JS 类型的文件在打包时使用了 cache-loader ,由于缓存的存在,会导致修改 options 后,配置不会生效。为确保配置能生效,请不要使用 cache-loader,并且配置 cache: false 来禁用缓存。