Skip to content

Commit

Permalink
add babel option
Browse files Browse the repository at this point in the history
  • Loading branch information
egoist committed Feb 7, 2017
1 parent bed3913 commit 864d654
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
9 changes: 5 additions & 4 deletions bin/vue-build
Original file line number Diff line number Diff line change
Expand Up @@ -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'))
}

Expand Down
8 changes: 7 additions & 1 deletion docs/build.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand Down Expand Up @@ -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

Expand Down

0 comments on commit 864d654

Please sign in to comment.