Support ts

This commit is contained in:
Sébastien Chopin 2017-05-20 11:36:35 +02:00
parent 48f617d174
commit 4cd48f3927
2 changed files with 12 additions and 15 deletions

View File

@ -11,8 +11,9 @@ const filenames = files.keys()
let storeData = {}
// Check if store/index.js exists
if (filenames.indexOf('./index.js') !== -1) {
storeData = getModule('./index.js')
const indexFilename = filenames.find((filename) => filename.includes('./index.'))
if (indexFilename) {
storeData = getModule(indexFilename)
}
// Store modules
@ -44,14 +45,10 @@ function getModule (filename) {
const file = files(filename)
const module = file.default || file
if (module.state && typeof module.state !== 'function') {
// eslint-disable-next-line no-console
console.error('[nuxt] store state should be a function.')
return
throw new Error('[nuxt] store state should be a function.')
}
if (module.commit) {
// eslint-disable-next-line no-console
console.error('[nuxt] store should export raw store options instead of an instance.')
return
throw new Error('[nuxt] store should export raw store options instead of an instance.')
}
return module
}

View File

@ -31,7 +31,7 @@ export default function ({ isClient, isServer }) {
hints: (this.dev ? false : 'warning')
},
resolve: {
extensions: ['.js', '.json', '.vue'],
extensions: ['.js', '.json', '.vue', '.ts'],
// Disable for now
alias: {
'~': join(this.srcDir),
@ -46,14 +46,14 @@ export default function ({ isClient, isServer }) {
'~components': join(this.srcDir, 'components')
},
modules: [
nodeModulesDir,
join(this.dir, 'node_modules')
join(this.dir, 'node_modules'),
nodeModulesDir
]
},
resolveLoader: {
modules: [
nodeModulesDir,
join(this.dir, 'node_modules')
join(this.dir, 'node_modules'),
nodeModulesDir
]
},
module: {
@ -75,8 +75,8 @@ export default function ({ isClient, isServer }) {
},
{ test: /\.css$/, use: styleLoader.call(this, 'css') },
{ test: /\.less$/, use: styleLoader.call(this, 'less', 'less-loader') },
{ test: /\.sass$/, use: styleLoader.call(this, 'sass', 'sass-loader?indentedSyntax') },
{ test: /\.scss$/, use: styleLoader.call(this, 'sass', 'sass-loader') },
{ test: /\.sass$/, use: styleLoader.call(this, 'sass', 'sass-loader?indentedSyntax&sourceMap') },
{ test: /\.scss$/, use: styleLoader.call(this, 'sass', 'sass-loader?sourceMap') },
{ test: /\.styl(us)?$/, use: styleLoader.call(this, 'stylus', 'stylus-loader') }
]
},