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) { %>
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)
}

View File

@ -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(/\//)

View File

@ -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 <img src="~/assets/nuxt.png" />
// with <img src="~/assets/nuxt.png" />
'assets': join(this.options.srcDir, 'assets'),
'static': join(this.options.srcDir, 'static')
},