Socket
Book a DemoInstallSign in
Socket

jass-vue-sfc

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

jass-vue-sfc

0.5.1
bundlerRubygems
Version published
Maintainers
1
Created
Source

Gem Version build

Jass::Vue::SFC – Vue SFC support for the Rails asset pipeline

Jass::Vue::SFC provides Vue Single File Component support for Sprockets and the Rails asset pipeline.

Vue SFCs will be compiled to ES modules, which can be imported using the new Rails Import Maps or regular <script module> tags.

Why?

Modern browsers support native loading of ES modules using the import statement. By leveraging the new Rails Import Maps, modular JS applications can be built without having to integrate a complex and tedious JS build pipeline.

However, framework-specific component formats like the Vue SFC format could not be used this way till now.

Jass::Vue::SFC enables the asset pipeline to compile .vue files to ES modules, allowing to build modular Vue applications in a clear and straightforward way, without the necessity of external build tools.

Installation

Gemfile

gem 'jass-vue-sfc'

JS dependencies

Add @vue/compiler-sfc to your JS dependencies:

$ yarn add @vue/compiler-sfc

Node.js

Jass::Vue::SFC depends on Nodo, which requires a working Node.js installation.

Usage

Place your .vue components inside your regular asset path, e.g. under app/assets/javascripts or app/javascript.

In app/javascript/components/HelloWorld.vue:

<script>
export default {
  data() {
    return {
      greeting: 'Hello World!'
    }
  }
}
</script>

<template>
  <p class="greeting">{{ greeting }}</p>
</template>

Then add the component to app/assets/config/manifest.js:

//= link app/javascript/components/HelloWorld.js

Make sure to link the file as .js instead of .vue. Sprockets will take care of converting it into an ES module.

In your HTML code, load the component as a module:

<%= javascript_include_tag 'HelloWorld.js', module: true %>

Components with imports

If you want to use module imports within your components, pin them in your Rails importmap:

# config/importmap.rb
pin 'vue'
pin 'HelloWorld.vue', to: 'HelloWorld.js'

Then just use them in your component:

<script>
import Vue from 'vue';
...
</script>

Limitations

Currently, the following things are not (yet) supported:

  • extracting the <style> section of the SFC
  • source maps

FAQs

Package last updated on 15 Oct 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.