From 2816c5687d92ee2be847109ec9158e1559646a79 Mon Sep 17 00:00:00 2001 From: outofcash Date: Wed, 4 Oct 2017 23:53:12 +0200 Subject: [PATCH] Support for .coffee files for store and middlewares --- lib/app/middleware.js | 4 ++-- lib/app/store.js | 4 ++-- lib/builder/webpack/base.config.js | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/app/middleware.js b/lib/app/middleware.js index 57e04073cb..30d6482c4a 100644 --- a/lib/app/middleware.js +++ b/lib/app/middleware.js @@ -1,5 +1,5 @@ <% if (middleware) { %> -let files = require.context('@/middleware', false, /^\.\/.*\.(js|ts)$/) +let files = require.context('@/middleware', false, /^\.\/.*\.(js|ts|coffee)$/) let filenames = files.keys() function getModule (filename) { @@ -12,7 +12,7 @@ let middleware = {} // Generate the middleware for (let filename of filenames) { - let name = filename.replace(/^\.\//, '').replace(/\.(js|ts)$/, '') + let name = filename.replace(/^\.\//, '').replace(/\.(js|ts|coffee)$/, '') middleware[name] = getModule(filename) } diff --git a/lib/app/store.js b/lib/app/store.js index d1e59efcd6..308b3bc88d 100644 --- a/lib/app/store.js +++ b/lib/app/store.js @@ -4,7 +4,7 @@ import Vuex from 'vuex' Vue.use(Vuex) // Recursive find files in {srcDir}/store -const files = require.context('@/store', true, /^\.\/.*\.(js|ts)$/) +const files = require.context('@/store', true, /^\.\/.*\.(js|ts|coffee)$/) const filenames = files.keys() // Store @@ -30,7 +30,7 @@ if (typeof storeData !== 'function') { } for (let filename of filenames) { - let name = filename.replace(/^\.\//, '').replace(/\.(js|ts)$/, '') + let name = filename.replace(/^\.\//, '').replace(/\.(js|ts|coffee)$/, '') if (name === 'index') continue let namePath = name.split(/\//) diff --git a/lib/builder/webpack/base.config.js b/lib/builder/webpack/base.config.js index 3da78d2640..6c14649c13 100644 --- a/lib/builder/webpack/base.config.js +++ b/lib/builder/webpack/base.config.js @@ -35,7 +35,7 @@ export default function webpackBaseConfig (name) { hints: this.options.dev ? false : 'warning' }, resolve: { - extensions: ['.js', '.json', '.vue', '.ts'], + extensions: ['.js', '.json', '.vue', '.ts', '.coffee'], alias: { '~': join(this.options.srcDir), '~~': join(this.options.rootDir), @@ -43,7 +43,7 @@ export default function webpackBaseConfig (name) { '@@': join(this.options.rootDir), // Used by vue-loader so we can use in templates - // with + // with 'assets': join(this.options.srcDir, 'assets'), 'static': join(this.options.srcDir, 'static') },