1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

開発環境限定のルートを設定する方法

Last updated at Posted at 2019-11-15

動機

masterブランチに食い込んでいるのに一般公開できないページが溜まってしまったので。

コード

index.js
import Vue from 'vue'
import Router from 'vue-router'
import DevRoute from './dev-route'

Vue.use(Router)

const router = new Router({
  routes: [
    ...DevRoute,
  }
})

export default router

dev-route.js
import test from '@/pages/dev/test'

const route = []

if (process.env.NODE_ENV !== 'production') {
  route.push(...[
    {
      path: '/dev/test',
      component: test 
    },
    // ルートを足すならここ
  ])
}

export default route

雑感

計画性を持って正しくブランチが切れていたら、
ビルドのたびにルートをコメント化するような羽目にはならなかったのだろう…。

スプレッド構文、超便利。

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?