Add build.babel option

This commit is contained in:
Sébastien Chopin 2016-11-18 10:38:47 +01:00
parent b431c80aa1
commit d4b8bc4f02
4 changed files with 14 additions and 7 deletions

View File

@ -54,6 +54,6 @@ export function getLocation (base) {
return (path || '/') + window.location.search + window.location.hash
}
exports.urlJoin = function () {
export function urlJoin () {
return [].slice.call(arguments).join('/').replace(/\/+/g, '/')
}

View File

@ -31,7 +31,8 @@ const defaults = {
},
vendor: [],
loaders: [],
plugins: []
plugins: [],
babel: {}
}
const defaultsLoaders = [
{

View File

@ -1,6 +1,7 @@
'use strict'
const vueLoaderConfig = require('./vue-loader.config')
const { defaults } = require('lodash')
const { join } = require('path')
const { urlJoin } = require('../../utils')
@ -50,20 +51,25 @@ module.exports = function () {
{
test: /\.vue$/,
loader: 'vue-loader',
options: vueLoaderConfig.call(this)
query: vueLoaderConfig.call(this)
},
{
test: /\.js$/,
loader: 'babel-loader',
exclude: /node_modules/,
options: {
presets: ['es2015', 'stage-2']
}
query: defaults(this.options.build.babel, {
presets: [
['es2015', { modules: false }],
'stage-2'
],
cacheDirectory: !!this.dev
})
}
]
},
plugins: this.options.build.plugins
}
console.log(config.module.rules[1])
// Add nuxt build loaders (can be configured in nuxt.config.js)
config.module.rules = config.module.rules.concat(this.options.build.loaders)
// Return config

View File

@ -1,6 +1,6 @@
{
"name": "nuxt",
"version": "0.4.8",
"version": "0.4.9",
"description": "A minimalistic framework for server-rendered Vue.js applications (inspired by Next.js)",
"main": "index.js",
"license": "MIT",