Quantcast
Channel: Node.jsタグが付けられた新着記事 - Qiita
Viewing all articles
Browse latest Browse all 8691

Vue.jsのコンポーネントのimport文をdynamic importに変換するcliコマンドを作りました

$
0
0

Vue.jsのコンポーネントのimportをdynamic importに変換するcliコマンドを作りました。
特定のディレクトリ配下のvueファイルを全てdynamic importに変換します。

ソースはこちらで公開しています。
https://github.com/harhogefoo/dynamic-import-converter

通常のcomponentのimport文
<template><div><hoge/><piyo/></div></template><script>importHogefrom"@/components/Hoge.vue"importPiyofrom"@/components/Piyo.vue"exportdefault{components:{Hoge,Piyo}}</script>
dynamic_importに変換
<template><div><hoge/><piyo/></div></template><script>exportdefault{components:{Hoge:()=>import("@/components/Hoge.vue"),Piyo:()=>import("@/components/Piyo.vue")}}</script>

使い方

$ yarn global add dynamic-import-converter
or
$ npm install-g dynamic-import-converter

$ dynamic-import-converter ./Vueファイルが格納されたディレクトリのパス/

バグ、改善要望などは、リポジトリのissueまで!
https://github.com/harhogefoo/dynamic-import-converter/issues


Viewing all articles
Browse latest Browse all 8691

Trending Articles