Support for .coffee files for store and middlewares

This commit is contained in:
outofcash 2017-10-04 23:53:12 +02:00
parent f654c9c94c
commit 2816c5687d
3 changed files with 6 additions and 6 deletions

View File

@ -1,5 +1,5 @@
<% if (middleware) { %> <% if (middleware) { %>
let files = require.context('@/middleware', false, /^\.\/.*\.(js|ts)$/) let files = require.context('@/middleware', false, /^\.\/.*\.(js|ts|coffee)$/)
let filenames = files.keys() let filenames = files.keys()
function getModule (filename) { function getModule (filename) {
@ -12,7 +12,7 @@ let middleware = {}
// Generate the middleware // Generate the middleware
for (let filename of filenames) { for (let filename of filenames) {
let name = filename.replace(/^\.\//, '').replace(/\.(js|ts)$/, '') let name = filename.replace(/^\.\//, '').replace(/\.(js|ts|coffee)$/, '')
middleware[name] = getModule(filename) middleware[name] = getModule(filename)
} }

View File

@ -4,7 +4,7 @@ import Vuex from 'vuex'
Vue.use(Vuex) Vue.use(Vuex)
// Recursive find files in {srcDir}/store // 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() const filenames = files.keys()
// Store // Store
@ -30,7 +30,7 @@ if (typeof storeData !== 'function') {
} }
for (let filename of filenames) { for (let filename of filenames) {
let name = filename.replace(/^\.\//, '').replace(/\.(js|ts)$/, '') let name = filename.replace(/^\.\//, '').replace(/\.(js|ts|coffee)$/, '')
if (name === 'index') continue if (name === 'index') continue
let namePath = name.split(/\//) let namePath = name.split(/\//)

View File

@ -35,7 +35,7 @@ export default function webpackBaseConfig (name) {
hints: this.options.dev ? false : 'warning' hints: this.options.dev ? false : 'warning'
}, },
resolve: { resolve: {
extensions: ['.js', '.json', '.vue', '.ts'], extensions: ['.js', '.json', '.vue', '.ts', '.coffee'],
alias: { alias: {
'~': join(this.options.srcDir), '~': join(this.options.srcDir),
'~~': join(this.options.rootDir), '~~': join(this.options.rootDir),