Skip to content

Commit

Permalink
force .vue extensions for better vetur autocompletion
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisvfritz committed Oct 2, 2019
1 parent 30c453d commit d2fd9bb
Show file tree
Hide file tree
Showing 26 changed files with 49 additions and 45 deletions.
2 changes: 1 addition & 1 deletion generators/new/view/view.ejs.t
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ to: "src/router/views/<%= h.changeCase.kebab(name) %>.vue"
const importName = h.changeCase.pascal(fileName)
const titleName = h.changeCase.title(name)
%><script>
import Layout from '@layouts/main'
import Layout from '@layouts/main.vue'
export default {
page: {
Expand Down
2 changes: 1 addition & 1 deletion jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ module.exports = {
globalTeardown: '<rootDir>/tests/unit/global-teardown',
setupTestFrameworkScriptFile: '<rootDir>/tests/unit/matchers',
testMatch: ['**/(*.)unit.js'],
moduleFileExtensions: ['js', 'json', 'vue'],
moduleFileExtensions: ['js', 'json'],
transform: {
'^.+\\.vue$': 'vue-jest',
'^.+\\.js$': 'babel-jest',
Expand Down
2 changes: 1 addition & 1 deletion src/components/_base-button.unit.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import BaseButton from './_base-button'
import BaseButton from './_base-button.vue'

describe('@components/_base-button', () => {
it('renders its content', () => {
Expand Down
2 changes: 1 addition & 1 deletion src/components/_base-icon.unit.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import BaseIcon from './_base-icon'
import BaseIcon from './_base-icon.vue'

describe('@components/_base-icon', () => {
it('renders a font-awesome icon', () => {
Expand Down
2 changes: 1 addition & 1 deletion src/components/_base-input-text.unit.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import BaseInputText from './_base-input-text'
import BaseInputText from './_base-input-text.vue'

describe('@components/_base-input-text', () => {
it('works with v-model', () => {
Expand Down
2 changes: 1 addition & 1 deletion src/components/_base-link.unit.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import BaseLink from './_base-link'
import BaseLink from './_base-link.vue'

const mountBaseLink = (options = {}) => {
return mount(BaseLink, {
Expand Down
2 changes: 1 addition & 1 deletion src/components/nav-bar-routes.unit.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import NavBarRoutes from './nav-bar-routes'
import NavBarRoutes from './nav-bar-routes.vue'

const mountRoutes = (options) => {
return mount(
Expand Down
2 changes: 1 addition & 1 deletion src/components/nav-bar.unit.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import NavBar from './nav-bar'
import NavBar from './nav-bar.vue'

describe('@components/nav-bar', () => {
it(`displays the user's name in the profile link`, () => {
Expand Down
2 changes: 1 addition & 1 deletion src/components/nav-bar.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<script>
import { authComputed } from '@state/helpers'
import NavBarRoutes from './nav-bar-routes'
import NavBarRoutes from './nav-bar-routes.vue'
export default {
components: { NavBarRoutes },
Expand Down
2 changes: 1 addition & 1 deletion src/main.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Vue from 'vue'
import App from './app'
import App from './app.vue'
import router from '@router'
import store from '@state/store'
import '@components/_globals'
Expand Down
4 changes: 2 additions & 2 deletions src/router/layouts/main.unit.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import MainLayout from './main'
import MainLayout from './main.vue'

describe('@layouts/main', () => {
describe('@layouts/main.vue', () => {
it('renders its content', () => {
const slotContent = '<p>Hello!</p>'
const { element } = shallowMount(MainLayout, {
Expand Down
2 changes: 1 addition & 1 deletion src/router/layouts/main.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script>
import NavBar from '@components/nav-bar'
import NavBar from '@components/nav-bar.vue'
export default {
components: { NavBar },
Expand Down
14 changes: 7 additions & 7 deletions src/router/routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ export default [
{
path: '/',
name: 'home',
component: () => lazyLoadView(import('@views/home')),
component: () => lazyLoadView(import('@views/home.vue')),
},
{
path: '/login',
name: 'login',
component: () => lazyLoadView(import('@views/login')),
component: () => lazyLoadView(import('@views/login.vue')),
meta: {
beforeResolve(routeTo, routeFrom, next) {
// If the user is already logged in
Expand All @@ -26,7 +26,7 @@ export default [
{
path: '/profile',
name: 'profile',
component: () => lazyLoadView(import('@views/profile')),
component: () => lazyLoadView(import('@views/profile.vue')),
meta: {
authRequired: true,
},
Expand All @@ -35,7 +35,7 @@ export default [
{
path: '/profile/:username',
name: 'username-profile',
component: () => lazyLoadView(import('@views/profile')),
component: () => lazyLoadView(import('@views/profile.vue')),
meta: {
authRequired: true,
beforeResolve(routeTo, routeFrom, next) {
Expand Down Expand Up @@ -78,7 +78,7 @@ export default [
{
path: '/404',
name: '404',
component: require('@views/_404').default,
component: require('@views/_404.vue').default,
// Allows props to be passed to the 404 page through route
// params, such as `resource` to define what wasn't found.
props: true,
Expand Down Expand Up @@ -110,13 +110,13 @@ function lazyLoadView(AsyncView) {
const AsyncHandler = () => ({
component: AsyncView,
// A component to use while the component is loading.
loading: require('@views/_loading').default,
loading: require('@views/_loading.vue').default,
// Delay before showing the loading component.
// Default: 200 (milliseconds).
delay: 400,
// A fallback component in case the timeout is exceeded
// when loading the component.
error: require('@views/_timeout').default,
error: require('@views/_timeout.vue').default,
// Time before giving up trying to load the component.
// Default: Infinity (milliseconds).
timeout: 10000,
Expand Down
2 changes: 1 addition & 1 deletion src/router/views/_404.unit.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import View404 from './_404'
import View404 from './_404.vue'

describe('@views/404', () => {
it('is a valid view', () => {
Expand Down
2 changes: 1 addition & 1 deletion src/router/views/_404.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script>
import Layout from '@layouts/main'
import Layout from '@layouts/main.vue'
export default {
page: {
Expand Down
2 changes: 1 addition & 1 deletion src/router/views/_loading.unit.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import Loading from './_loading'
import Loading from './_loading.vue'

describe('@views/loading', () => {
it('is a valid view', () => {
Expand Down
2 changes: 1 addition & 1 deletion src/router/views/_loading.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script>
import Layout from '@layouts/main'
import Layout from '@layouts/main.vue'
export default {
page: {
Expand Down
2 changes: 1 addition & 1 deletion src/router/views/_timeout.unit.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import Timeout from './_timeout'
import Timeout from './_timeout.vue'

describe('@views/timeout', () => {
it('is a valid view', () => {
Expand Down
4 changes: 2 additions & 2 deletions src/router/views/_timeout.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<script>
import axios from 'axios'
import Layout from '@layouts/main'
import LoadingView from '@views/_loading'
import Layout from '@layouts/main.vue'
import LoadingView from './_loading.vue'
export default {
page: {
Expand Down
2 changes: 1 addition & 1 deletion src/router/views/home.unit.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import Home from './home'
import Home from './home.vue'

describe('@views/home', () => {
it('is a valid view', () => {
Expand Down
2 changes: 1 addition & 1 deletion src/router/views/home.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<script>
import appConfig from '@src/app.config'
import Layout from '@layouts/main'
import Layout from '@layouts/main.vue'
export default {
page: {
Expand Down
2 changes: 1 addition & 1 deletion src/router/views/login.unit.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import Login from './login'
import Login from './login.vue'

describe('@views/login', () => {
it('is a valid view', () => {
Expand Down
2 changes: 1 addition & 1 deletion src/router/views/login.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script>
import Layout from '@layouts/main'
import Layout from '@layouts/main.vue'
import { authMethods } from '@state/helpers'
import appConfig from '@src/app.config'
Expand Down
2 changes: 1 addition & 1 deletion src/router/views/profile.unit.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import Profile from './profile'
import Profile from './profile.vue'

describe('@views/profile', () => {
it('is a valid view', () => {
Expand Down
2 changes: 1 addition & 1 deletion src/router/views/profile.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script>
import Layout from '@layouts/main'
import Layout from '@layouts/main.vue'
export default {
page() {
Expand Down
28 changes: 16 additions & 12 deletions vue.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,26 @@ const appConfig = require('./src/app.config')

/** @type import('@vue/cli-service').ProjectOptions */
module.exports = {
configureWebpack: {
// https://github.com/neutrinojs/webpack-chain/tree/v4#getting-started
chainWebpack(config) {
// We provide the app's title in Webpack's name field, so that
// it can be accessed in index.html to inject the correct title.
name: appConfig.title,
config.set('name', appConfig.title)

// Set up all the aliases we use in our app.
resolve: {
alias: require('./aliases.config').webpack,
},
performance: {
// Only enable performance hints for production builds,
// outside of tests.
hints:
process.env.NODE_ENV === 'production' &&
config.resolve.alias.clear().merge(require('./aliases.config').webpack)

// Don't allow importing .vue files without the extension, as
// it's necessary for some Vetur autocompletions.
config.resolve.extensions.delete('.vue')

// Only enable performance hints for production builds,
// outside of tests.
config.performance.hints(
process.env.NODE_ENV === 'production' &&
!process.env.VUE_APP_TEST &&
'warning',
},
'warning'
)
},
css: {
// Enable CSS source maps.
Expand Down

0 comments on commit d2fd9bb

Please sign in to comment.