• Stars
    star
    188
  • Rank 205,563 (Top 5 %)
  • Language
    JavaScript
  • Created over 4 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Use Vue.js templates and Vue.js single file components in Eleventy.

eleventy Logo

eleventy-plugin-vue for Vue 3 🕚⚡️🎈🐀

Adds Vue Single File Component (SFC) support to Eleventy. Eleventy processes .vue SFC files as Eleventy templates and outputs zero-bundle size server rendered components.

Read more about the goals of this plugin (and a full tutorial!) at Eleventy and Vue, a match made to power Netlify.com

Installation

npm install @11ty/eleventy-plugin-vue
  • 1.x requires Eleventy 1.0.0 or newer
  • 0.2.x encouraged to use Eleventy 0.11.1 or newer (for incremental Vue component builds)
  • 0.1.x requires Eleventy 0.11.0 or newer

Changelog

  • 1.0.0 (Milestone) Works with Vue 3. Adds Windows support.
  • 0.6.x (Milestone)
  • 0.3.1 (Milestone)
  • 0.3.0 (Milestone) More consistent incremental builds. Performance improvements.
  • 0.2.1 (Milestone) adds incremental builds for Eleventy Vue components to avoid unnecessary repeat work. Fixes bug with permalink strings returned from Vue Single File Component data.
  • 0.1.x converted to use a Single File Components for everything (templates, components, etc), instead of 0.0.x’s string templates with front matter.

Features

  • Builds *.vue’s Single File Components, both in the input directory and in Eleventy’s includes directory. .vue files in the includes directory are available for import. Same as any Eleventy template syntax, includes do not write files to your output directory.
  • Works with Vue’s Single File Components, including with scoped CSS.
  • Data from SFC files feeds into the data cascade (similar to front matter)
  • All JavaScript Template Functions (see https://www.11ty.dev/docs/languages/javascript/#javascript-template-functions), Universal Filters, Universal Shortcodes, Universal Paired Shortcodes are available as Vue methods (global functions to use in templates and child components).
  • page Eleventy supplied data is also available globally in all components.

Not Yet Available

  • Using .vue templates as Eleventy layouts is not yet supported. Subscribe to this issue at #5.
  • Does not yet embed any client-side JavaScript from inside single file components into the output for use on the client.
  • lang on <template>, <style>, or <script> is not yet supported.

Usage

Add to Configuration File

Usually .eleventy.js:

const eleventyVue = require("@11ty/eleventy-plugin-vue");

module.exports = function(eleventyConfig) {
  // Use Defaults
  eleventyConfig.addPlugin(eleventyVue);
};

Customize with Options

const eleventyVue = require("@11ty/eleventy-plugin-vue");

module.exports = function(eleventyConfig) {
  // OR, Use your own options
  eleventyConfig.addPlugin(eleventyVue, {
    // Directory to store compiled Vue single file components
    cacheDirectory: ".cache/vue/",

    // Pass in a file or multiple .vue files to limit compilation
    // If this is empty, the plugin will search for all *.vue files
    input: [],

    // Use postcss in the single file components
    rollupPluginVueOptions: {
      style: {
        postcssPlugins: [
          require("autoprefixer"),
          require("postcss-nested")
        ]
      }
    },

    // Passed to rollup.rollup
    rollupOptions: {
      // Declare your own external dependencies
      external: [],

      // Use your own Rollup plugins
      plugins: [],
    },
  });
};

For a full list of rollupPluginVueOptions, see rollup-plugin-vue’s Options.

Advanced: Use with eleventy-assets

Compatible with @11ty/eleventy-plugin-vue 0.0.5 and newer.

Eleventy’s Assets plugin lets you manage your own Inline CSS or JavaScript. For the first version of the Eleventy Vue plugin, you can reuse an existing CSS code manager from eleventy-assets add CSS from your Vue.js Single File Components too.

const eleventyVue = require("@11ty/eleventy-plugin-vue");
const { InlineCodeManager } = require("@11ty/eleventy-assets");

module.exports = function(eleventyConfig) {
  let myCssManager = new InlineCodeManager();

  eleventyConfig.addPlugin(eleventyVue, {
    // Re-use an existing `eleventy-assets` Manager
    assets: {
      css: myCssManager
    }
  });
};

Advanced: Run async things before component render

Available with Eleventy 1.0+ and Eleventy Vue Plugin 0.6+

Use serverPrefetch to tell the component to do a few async things before it renders the component.

Below is an example of a Vue template that uses the Eleventy Render Plugin to render Markdown (either in an external file or a string).

<template>
  <header v-html="content"/>
</template>
<script>
export default {
  async serverPrefetch() {
    // let content = await this.renderFile("./_includes/blogpost.md", "md");
    this.content = await this.renderTemplate("# Title", "md");
  }
}
</script>

More Repositories

1

eleventy

A simpler site generator. Transforms a directory of templates (of varying types) into HTML.
JavaScript
16,829
star
2

webc

Single File Web Components
JavaScript
1,163
star
3

eleventy-base-blog

A starter repository for a blog web site using the Eleventy static site generator.
Nunjucks
990
star
4

11ty-website

Documentation site for the Eleventy static site generator.
JavaScript
414
star
5

eleventy-img

Utility to perform build-time image transformations.
JavaScript
385
star
6

is-land

A new performance-focused way to add interactive client-side components to your web site.
JavaScript
351
star
7

eleventy-fetch

Utility to cache any remote asset: Image, Video, Web Font, CSS, JSON, etc
JavaScript
122
star
8

eleventy-plugin-syntaxhighlight

A pack of Eleventy plugins for syntax highlighting in Markdown, Liquid, and Nunjucks templates.
JavaScript
115
star
9

eleventy-plugin-webc

Adds support for WebC *.webc files to Eleventy
JavaScript
104
star
10

eleventy-plugin-vite

A plugin to use Vite with Eleventy
JavaScript
104
star
11

api-screenshot

A service to add web page screenshots to your Eleventy sites.
JavaScript
97
star
12

eleventy-navigation

A plugin for creating hierarchical navigation in Eleventy projects. Supports breadcrumbs too!
JavaScript
92
star
13

eleventy-dev-server

A minimal generic web-development web server.
JavaScript
86
star
14

eleventy-activity-feed

Create one centralized RSS feed for all of the content you create across the web (aggregates from Twitter, RSS, Atom, Mastodon, YouTube)
JavaScript
81
star
15

eleventy-plugin-rss

A pack of Eleventy plugins for generating an RSS feed.
JavaScript
78
star
16

demo-eleventy-serverless

Run Eleventy in a serverless function
JavaScript
58
star
17

eleventy-upgrade-help

Helper plugin when upgrading your Eleventy project to a new major version.
JavaScript
52
star
18

api-indieweb-avatar

Return an optimized avatar image from a domain name input.
JavaScript
50
star
19

eleventy-plugin-bundle

Little bundles of code, little bundles of joy.
JavaScript
48
star
20

eleventy-plugin-inclusive-language

A linter plugin to check for inclusive language in markdown files.
JavaScript
39
star
21

demo-eleventy-serverless-oauth

A demo project using OAuth to secure some of your Eleventy Serverless routes.
JavaScript
38
star
22

eleventy-base-webc

A minimalist bare-bones starter project using Eleventy and WebC.
JavaScript
36
star
23

eleventy-assets

Code-split your CSS in Eleventy.
JavaScript
30
star
24

11ty-community

29
star
25

api-opengraph-image

A service that returns an optimized OpenGraph Image from a domain name input.
JavaScript
24
star
26

api-sparkline

Service to return sparkline SVG images.
JavaScript
19
star
27

eleventy-plugin-directory-output

Group and sort Eleventy’s verbose output by directory (and show file size with benchmarks)
JavaScript
17
star
28

tugboat

A modern starter project using Eleventy and WebC.
HTML
17
star
29

eleventy-server-browsersync

An Eleventy server plugin to use Browsersync with Eleventy 2.0+.
JavaScript
13
star
30

demo-eleventy-edge

Liquid
12
star
31

giffleball

Giffleball is a web site for Gifs
HTML
12
star
32

eleventy-community

A repository for Eleventy community discussions.
10
star
33

demo-eleventy-img-netlify-cache

A demo to show how to re-use Eleventy Image’s disk cache across Netlify builds.
JavaScript
10
star
34

eleventy-utils

Lower level internal utilities to share amongst Eleventy packages
JavaScript
9
star
35

api-img

A runtime service to optimize hosted images.
JavaScript
8
star
36

api-explorer

A simple way to browse the different runtime services provided by Eleventy
Nunjucks
8
star
37

demo-webc-counter

A progressively enhanced server-rendered form-aware web component counter using WebC
JavaScript
8
star
38

demo-eleventy-js-front-matter

Demo of free-form JavaScript in front matter to populate the Data Cascade.
Nunjucks
8
star
39

eleventy-benchmark

Eleventy Benchmark Speed Regression Test
HTML
8
star
40

11ty-logo

11ty logo built for a browser.
JavaScript
7
star
41

eleventy-dependency-tree

Returns an unordered array of local paths to dependencies of a node JavaScript file (everything it or any of its dependencies require()s)
JavaScript
7
star
42

eleventy-plugin-img

A plugin to perform runtime image transformations.
JavaScript
6
star
43

eleventy-img-cloud

Run eleventy-img in the CLOUD ⛅️
JavaScript
6
star
44

eleventy-data-transistor-fm

An Eleventy data plugin to source transistor.fm episodes.
JavaScript
5
star
45

api-generator

Find the <meta name="generator"> for a web site
JavaScript
4
star
46

demo-webc-image-compare

Server rendered image comparison web components built using WebC
JavaScript
4
star
47

lodash-custom

A custom, focused build of lodash exclusively for use internally in Eleventy.
JavaScript
4
star
48

demo-webc-shadow-dom

Demo of rendering modes of WebC components: Shadow DOM versus HTML
JavaScript
3
star
49

eleventy-base-plugin

A starter project for a Plugin for the Eleventy static site generator.
JavaScript
3
star
50

eleventy-import-disqus

A manual process to import existing exported disqus.xml content into an eleventy blog.
JavaScript
2
star
51

.github

Special README repository
Shell
1
star
52

demo-eleventy-upgrade-help

A test project to demonstrate usage of the eleventy-upgrade-help plugin
JavaScript
1
star
53

eleventy-sample-jstl

An Eleventy sample project using JSTL files.
1
star
54

demo-eleventy-from-scratch-blog

Companion code to the “6 Minutes to Build a Blog from Scratch” tutorial
HTML
1
star