Gruntfile.js中的Javascript变量? [英] Javascript variables in Gruntfile.js?
问题描述
我正在维护一个广泛使用Grunt的Web应用程序。我必须缩小,将我的html,css,js文件复制到不同时间的不同位置。所以为了简单起见,我在我的GruntFile.js中创建了一个简单的JavaScript变量,如下所示:
var path =C:/ DIST;
$ b uglify:{
options:{
mangle:false
},
my_target:{
files:{
path + '/js/jsFile.js':['src / js / jquery-1.10.2.min.js']
}
}
}
当我建立这个时,我收到以下错误:
>> SyntaxError:意外的标记+
无法在我的GruntFile.js中使用路径变量。因为我有10个位置路径。
另一种方式是使用Grunt模板:
grunt.initConfig({
path:'C:/ dist /',
uglify:{
options:{
mangle:false
$,
'<%=路径%> js / jsFile.js':['src / js / jquery-1.10.2.min.js']
}
});
I'm maintaining a web application that uses Grunt extensively. I have to minify, copy my html, css, js files to different locations in different times. So to make it easy I created a simple javascript variable in my GruntFile.js as follows:
var path="C:/dist";
uglify: {
options: {
mangle: false
},
my_target: {
files: {
path+'/js/jsFile.js': ['src/js/jquery-1.10.2.min.js']
}
}
}
When I am building this i am getting the following error
>> SyntaxError: Unexpected token +
Can't I Use path variable in my GruntFile.js. Because I have 10 location paths.
Another way, is to utilize Grunt templates:
grunt.initConfig({
path: 'C:/dist/',
uglify: {
options: {
mangle: false
},
'<%= path %>js/jsFile.js': ['src/js/jquery-1.10.2.min.js']
}
});
这篇关于Gruntfile.js中的Javascript变量?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!