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

@rouche/vue-auto-tmpl-loader

v1.1.3

Published

Automatically load files associated with a vuejs .vue template. Like <template ... /> <script ... /> <style ... /> if they exists.

Downloads

1

Readme

vue-auto-tmpl-loader

Vue.js 2.0 webpack loader for automatic fetching of the files that can be separated from a .vue template if they exists in the same directory.

install

npm install --save-dev @rouche/vue-auto-tmpl-loader

Concept

Lets say you want to separate the concern for a .vue template, you have to repeat those lines.

<script lang="ts" src="./mycomponent.ts">
</script>

With this loader. You can leave the .vue with only the template, or even completelly empty.

The only important part is to keep the files along the template with the same name.

├── mycomponent
│   ├── mycomponent.vue (empty)
│   ├── mycomponent.vue.html
│   ├── mycomponent.ts
│   ├── mycomponent.scss
│   └── mycomponent.scoped.scss

Compatible (and tested) with

  • webpack 4
  • vue-cli 3
  • vue-loader
  • vue-template-loader
  • typescript
  • sass-loader
  • etc..

Project with all tests: https://github.com/Rouche/vue-ts-template

It should run with mostly anything since it just modify the loaded file just before passing it to the next loader (vue-loader)

Webpack Configuration

Add vue-auto-tmpl-loader at 1st position to your webpack configuration.

vue.config.js (vue-cli 3)

config.module
	.rule('vue')
	.use('vue-auto-tmpl-loader')
	.loader('@rouche/vue-auto-tmpl-loader')
	.options({
		debug: true
	})
	.end();

Option Reference

startTag

  • type: string
  • default: '__{{'

endTag

  • type: string
  • default: '}}__'

Mustache is used to replace the src in section. ex: <script lang="xx" src="__{{{mustacheData.prop}}}__"></section> It is the only template engine that you can customize tags so it does not interfere with vuejs {{prop}} that need to be in your final template untouched.

mustacheData is the object used for render()

    let mustacheData = {
        path: (This is a path.parse(resourcePath) of original .vue file)
        sections: {
		(Information for each sections, check in code for easy understanding)
	}, 
    };

TL;DR

The main use, is to stop having to type those same lines of codes in .vue files. (or ts files) :

<template src="template.html">
</template>

<script lang="ts" src="component.ts">
</script>

<style scoped lang="scss" src="style.scss">
</style>

or

import WithRender from './helloworld.html?style=./helloworld.scss';

/**
 * Example for vue-template-loader
 */
@WithRender
@Component
bla bla

Just put your files in the same directory of your .vue and thats it! @WithRender is nice https://github.com/ktsn/vue-template-loader But you still need to repeat imports in your code. And its prone to copy paste.

License

ISC