[英]grunt-babel breaks file formatting (new lines and spaces)
I've just started using babel with grunt-babel in my application.我刚刚开始在我的应用程序中使用babel和grunt-babel 。 But I encounter some behavior I want to avoid:
但是我遇到了一些我想避免的行为:
Before babel :在 babel 之前:
(function() {
'use strict';
angular
.module('app')
.controller('Ctrl', Ctrl);
Ctrl.$inject = ['$stateParams'];
function Ctrl($stateParams) {
}
})();
After babel :在 babel 之后:
(function () {
'use strict';
angular.module('app.standingOrder').controller('Ctrl', Ctrl);
Ctrl.$inject = ['$stateParams'];
function Ctrl($stateParams) {}
})();
My grunt task looks like this:我的grunt 任务如下所示:
babel: {
options: {
sourceMap: false,
blacklist: ['strict']
},
dist: {
files: [
{
src: [ 'src/**/*.js' ],
cwd: '<%= build_dir %>',
dest: '<%= build_dir %>',
expand: true
}
]
}
},
Note that babel removed blank lines, added/removed spaces that breaks previous formatting.请注意,babel 删除了空行,添加/删除了破坏先前格式的空格。
Is there any way to avoid this and keep my formatting?有什么办法可以避免这种情况并保留我的格式吗?
The retainLines
option will attempt to preserve your line numbers. retainLines
选项将尝试保留您的行号。 https://babeljs.io/docs/usage/options/ https://babeljs.io/docs/usage/options/
I think source maps are probably the best option, though they require a bit more work to manage.我认为源映射可能是最好的选择,尽管它们需要更多的工作来管理。
You can use the repl to see what babel's gonna do https://babeljs.io/repl/您可以使用 repl 来查看 babel 会做什么https://babeljs.io/repl/
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.