Rollup Plugin for TypeScript Vue 2 Components

0.6.0 · abandoned · verified Tue Apr 21

The `rollup-plugin-ts-vue` package, currently at version 0.6.0 (last updated in August 2021), is a Rollup plugin designed to bundle Vue 2 Single-File Components (SFCs) that are written in TypeScript and utilize SCSS for styling. It distinguishes itself by integrating directly with TypeScript's API, aiming to simplify the build process by reducing reliance on external tools such as Babel or Webpack. A key feature is its ability to handle `tsconfig.json` path aliases (e.g., `@/components`), which Rollup typically doesn't resolve by default. The plugin's release cadence is not regular, with its most recent update being driven by security advisories rather than active feature development. It targets a niche of developers who prefer a minimalist Rollup-centric toolchain for their Vue 2 projects with strong TypeScript typing, though it only offers partial support for scoped CSS.

Common errors

Warnings

Install

Imports

Quickstart

This Rollup configuration demonstrates how to bundle a Vue 2 application with TypeScript and SCSS using `rollup-plugin-ts-vue`, resolving node modules and outputting CSS separately.

import resolve from '@rollup/plugin-node-resolve';
import vue from 'rollup-plugin-ts-vue';

export default {
    input: './src/main.ts',
    output: {
        name: 'app',
        format: 'iife',
        file: './dist/js/app.js',
        globals: {
            'vue': 'Vue',
            'vue-router': 'VueRouter',
            'vuex': 'Vuex',
            'vue-property-decorator': 'VueClassComponent',
            'vue-class-component': 'VueClassComponent',
            'axios': 'axios'
        },
        sourcemap: true,
        sourcemapFile: './dist/js/app.js.map'
    },
    plugins: [
        resolve(),
        vue(null, { // null defaults to tsconfig.json
            output: './dist/css/site.css',
            includePaths: ['src/scss']
        })
    ],
    external: [
        'vue',
        'vue-router',
        'vuex',
        'vue-class-component',
        'vue-property-decorator',
        'axios'
    ]
}

view raw JSON →