From 864d654fdb5d3876601791c4509b905963c5ae0c Mon Sep 17 00:00:00 2001 From: EGOIST <0x142857@gmail.com> Date: Tue, 7 Feb 2017 14:26:44 +0800 Subject: [PATCH] add `babel` option --- bin/vue-build | 9 +++++---- docs/build.md | 8 +++++++- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/bin/vue-build b/bin/vue-build index 4fffcda263..e1b5f1e9bb 100755 --- a/bin/vue-build +++ b/bin/vue-build @@ -114,17 +114,18 @@ if (options.postcss) { } } -var babelOptions = { +var babelOptions = Object.assign({ babelrc: true, cacheDirectory: true, sourceMaps: production ? 'both' : false, presets: [] -} +}, options.babel) -var hasBabelRc = fs.existsSync('.babelrc') -if (hasBabelRc) { +var useBabelRc = babelOptions.babelrc && fs.existsSync('.babelrc') +if (useBabelRc) { console.log('> Using .babelrc in current working directory') } else { + babelOptions.babelrc = false babelOptions.presets.push(require.resolve('babel-preset-vue-app')) } diff --git a/docs/build.md b/docs/build.md index 24ec128580..38b5cf0902 100644 --- a/docs/build.md +++ b/docs/build.md @@ -147,6 +147,12 @@ PostCSS options, if it's an `Array` or `Function`, the default value will be ove } ``` +#### babel + +Type: `Object` + +[Babel options)(https://github.com/babel/babel-loader#options). You can set `babel.babelrc` to false to disable using `.babelrc`. + #### html Type: `Object` `Array` @@ -285,7 +291,7 @@ By default we only use a single babel preset: [babel-preset-vue-app](https://git - Transform `async/await` and `generator` - Transform Vue JSX -You can populate a `.babelrc` in project root directory to override it. +You can set `babel` option in config file or populate a `.babelrc` in project root directory to override it. ### Copy static files