我不能让我的生活让这个资产管道工作。
我补充说:
compile ":babel-asset-pipeline:1.3.1"
到我的BuildConfig.groovy
和
grails.asset.babel.enabled = true
grails.asset.babel.processJsFiles = true
到我的Config.groovy
在我的application.js中我只有:
// This is a manifest file that'll be compiled into application.js.
//
// Any JavaScript file within this directory can be referenced here using a relative path.
//
// You're free to add application-wide JavaScript to this file, but it's generally better
// to create separate JavaScript files as needed.
//
//= require jquery
//= require_tree .
//= require_self
if (typeof jQuery !== 'undefined') {
(function($) {
$('#spinner').ajaxStart(function() {
$(this).fadeIn();
}).ajaxStop(function() {
$(this).fadeOut();
});
})(jQuery);
}
class Test {
render() {
return (
"TEST"
);
}
}
哪个应转换为:
// This is a manifest file that'll be compiled into application.js.
//
// Any JavaScript file within this directory can be referenced here using a relative path.
//
// You're free to add application-wide JavaScript to this file, but it's generally better
// to create separate JavaScript files as needed.
//
//= require jquery
//= require_tree .
//= require_self
'use strict';
var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
if (typeof jQuery !== 'undefined') {
(function ($) {
$('#spinner').ajaxStart(function () {
$(this).fadeIn();
}).ajaxStop(function () {
$(this).fadeOut();
});
})(jQuery);
}
var Test = (function () {
function Test() {
_classCallCheck(this, Test);
}
_createClass(Test, [{
key: 'render',
value: function render() {
return "TEST";
}
}]);
return Test;
})();
根据此在线工具https://babeljs.io/repl/
但似乎我的application.js永远不会被处理。有什么问题?
答案 0 :(得分:2)
我刚刚合并了针对该问题的拉取请求。 实际上文档是错误的。资产配置的命名空间不是grails.asset,而是grails.asset s
因此,如果您将配置更新为
grails.assets.babel.enabled = true
grails.assets.babel.processJsFiles = true
它应该有用