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-toolchain

v0.8.4

Published

Simplified toolchain for Vue development

Downloads

49

Readme

vue-toolchain

This is a small suite of tools for bundling and testing a Vue project. Its main advantages over vue-loader and others is:

  • Ability to load and test .vue files in Node
  • A Webpack loader that produces less output, and
  • A Gulp utility for integrating <style> into your Gulp pipeline.

vue-toolchain/register

Example (change register.js to vue-toolchain/register)

You can use this with Mocha to launch tests that require Vue files. Say you have some tests, Button.spec.js for Button.vue. Assume Button.spec.js looks like this:

const Button = require('./Button.vue').default;
const Vue = require('vue');
const vm = new Vue(Button);

vm.text = 'Click Me!';
vm.$mount();

expect(vm._vnode.children[0].text).toBe('Click me!')

You can use vue-toolchain to run the tests in Node like this:

$ mocha -r vue-toolchain/register Button.spec.js

vue-toolchain/loader

Example

Use the loader like any Webpack loader. Sourcemaps are supported, but many of the vue-loader features like HMR are not yet supported. Stripping out CSS is specifically not supported because of a preference to use Gulp for styles (more on that below).

module.exports = {
  module: {
    rules: [
      {test: /\.vue$/, use: 'vue-toolchain/loader'}
    ]
  }
};

One benefit of using vue-toolchain's loader is that unlike the upstream vue-loader, it does not use a combination of 3 Webpack loaders and 3 JS modules for one component. vue-toolchain's loader uses an alternate approach: using Babel, modify the AST of the component to add the render function. In large applications, this can save you tens of kilobytes.

vue-toolchain/gulp-vue-to-style-stream

Example

You can pipe the .vue files through this Gulp util in order to get styles out. Doing it this way allows you to have variables defined in other SCSS files which you can then use in your component <style>. (If you do want to use variables, just make sure they concatenate in the right order - see the demo for how).

const gulp = require('gulp');
const vueToStyle = require('vue-toolchain/gulp-vue-to-style-stream');
const scss = require('gulp-sass');
const concat = require('gulp-concat');

gulp.task('scss', () => {
  gulp.src('*.vue')
    .pipe(vueToStyle())
    .pipe(concat('styles.scss'))
    .pipe(scss())
    .pipe(gulp.dest('.'));
});