mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-27 16:12:12 +00:00
Support for .coffee files for store and middlewares
This commit is contained in:
parent
f654c9c94c
commit
2816c5687d
@ -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)
|
||||
}
|
||||
|
||||
|
@ -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(/\//)
|
||||
|
@ -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')
|
||||
},
|
||||
|
Loading…
Reference in New Issue
Block a user