From ce1b4819a490da80450b4dd1d17f9e144b00c990 Mon Sep 17 00:00:00 2001 From: Davit Svanidze Date: Thu, 28 May 2020 09:18:58 +0200 Subject: [PATCH] rollup supports now vue "@" alias - e.g. '@/components/HelloWorld.vue' --- package.json | 1 + rollup.config.js | 16 ++++++++++++++++ src/index.ts | 2 +- 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 794bed4..a9c3f8d 100755 --- a/package.json +++ b/package.json @@ -40,6 +40,7 @@ }, "devDependencies": { "@mdi/font": "^4.6.95", + "@rollup/plugin-alias": "^3.1.0", "@rollup/plugin-node-resolve": "^6.0.0", "@types/node": "^12.12.14", "@vue/cli-plugin-babel": "^4.1.1", diff --git a/rollup.config.js b/rollup.config.js index d81b958..f1ed38c 100644 --- a/rollup.config.js +++ b/rollup.config.js @@ -16,6 +16,13 @@ import resolve from '@rollup/plugin-node-resolve'; import del from 'rollup-plugin-delete' import css from 'rollup-plugin-css-porter'; import sass from 'rollup-plugin-sass'; +import alias from '@rollup/plugin-alias' +import path from 'path' + +const projectRootDir = path.resolve(__dirname) +const customResolver = resolve({ + extensions: ['.ts', '.js', '.vue', '.sass', '.scss'] +}) export default { input: 'src/index.ts', // our source file @@ -91,6 +98,15 @@ export default { }), sass(), css(), + alias({ + entries: [ + { + find: '@', + replacement: path.resolve(projectRootDir, 'src'), + } + ], + customResolver, + }), resolve(), // terser() // minifies generated bundles diff --git a/src/index.ts b/src/index.ts index 7eb9583..12ca992 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,6 +1,6 @@ // import Vuetify, { VBtn } from 'vuetify/lib'; import Vue from 'vue'; -import HelloWorld from './components/HelloWorld.vue'; +import HelloWorld from '@/components/HelloWorld.vue'; /** * Fügt eine "install" function bei MLiveForce hinzu