8000 add `babel` option · coder-caicai/vue-cli@864d654 · GitHub
[go: up one dir, main page]

Skip to content

Commit 864d654

Browse files
committed
add babel option
1 parent bed3913 commit 864d654

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed

bin/vue-build

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -114,17 +114,18 @@ if (options.postcss) {
114114
}
115115
}
116116

117-
var babelOptions = {
117+
var babelOptions = Object.assign({
118118
babelrc: true,
119119
cacheDirectory: true,
120120
sourceMaps: production ? 'both' : false,
121121
presets: []
122-
}
122+
}, options.babel)
123123

124-
var hasBabelRc = fs.existsSync('.babelrc')
125-
if (hasBabelRc) {
124+
var useBabelRc = babelOptions.babelrc && fs.existsSync('.babelrc')
125+
if (useBabelRc) {
126126
console.log('> Using .babelrc in current working directory')
127127
} else {
128+
babelOptions.babelrc = false
128129
babelOptions.presets.push(require.resolve('babel-preset-vue-app'))
129130
}
130131

docs/build.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,12 @@ PostCSS options, if it's an `Array` or `Function`, the default value will be ove
147147
}
148148
```
149149

150+
#### babel
151+
152+
Type: `Object`
153+
154+
[Babel options)(https://github.com/babel/babel-loader#options). You can set `babel.babelrc` to false to disable using `.babelrc`.
155+
150156
#### html
151157

152158
Type: `Object` `Array`
@@ -285,7 +291,7 @@ By default we only use a single babel preset: [babel-preset-vue-app](https://git
285291
- Transform `async/await` and `generator`
286292
- Transform Vue JSX
287293

288-
You can populate a `.babelrc` in project root directory to override it.
294+
You can set `babel` option in config file or populate a `.babelrc` in project root directory to override it.
289295

290296
### Copy static files
291297

0 commit comments

Comments
 (0)
0