Visual studio 2013 停止grunt编译引用
由于输出的灵活性,我最近从使用Web Essentials切换到使用grunt ts来编译我的typescript文件。我切换的部分原因是我不希望所有文件都单独编译,也不希望所有文件都编译成一个文件。两者我都要。由于我最近开始在很多任务中使用grunt,我想我也可以切换我的TS构建 这是我的文件Visual studio 2013 停止grunt编译引用,visual-studio-2013,gruntjs,typescript,grunt-ts,Visual Studio 2013,Gruntjs,Typescript,Grunt Ts,由于输出的灵活性,我最近从使用Web Essentials切换到使用grunt ts来编译我的typescript文件。我切换的部分原因是我不希望所有文件都单独编译,也不希望所有文件都编译成一个文件。两者我都要。由于我最近开始在很多任务中使用grunt,我想我也可以切换我的TS构建 这是我的文件 module.exports = function (grunt) { grunt.initConfig({ pkg: grunt.file.readJSON('package.
module.exports = function (grunt) {
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
dirs: {
distribution: 'script/dist',
ts_root: 'script/src',
ts_controllers: 'script/src/controllers'
},
ts: {
apprunner: {
src: ['<%= dirs.ts_root %>/main.ts'],
out: '<%= dirs.distribution %>/src/main.js',
options: {
target: 'es5'
}
},
controllers: {
src: ['<%= dirs.ts_controllers %>/*.ts'],
out: '<%= dirs.distribution %>/src/controllers.js'
options: {
target: 'es5'
}
}
}
});
grunt.loadNpmTasks('grunt-ts');
grunt.registerTask('default', ['ts']);
};
Grunt很好地编译了my controllers.js文件:
var wctApp;
(function (wctApp) {
(function (controllers) {
var ExampleController = (function () {
function ExampleController() {
}
return ExampleController;
})();
controllers.ExampleController = ExampleController;
})(wctApp.controllers || (wctApp.controllers = {}));
var controllers = wctApp.controllers;
})(wctApp || (wctApp = {}));
但它在main.js文件中编译相同的代码
如果我从主文件中删除引用,它将不会生成,因为它找不到ExampleController。如何保留对该文件的引用,但不在main.js文件中编译它。不要使用out。因为out将所有TypeScript文件合并为一个。如果需要重定向到其他文件夹,请改用outDir。或者最好不要使用任何no out no outDir,它会将生成的JS放在文件旁边 谢谢,这很有道理,而且很有效。出于好奇,有没有办法使用outDir方法指定不同的编译文件名?或者它将始终与源JS文件相同?@JamesHay它将始终相同
var wctApp;
(function (wctApp) {
(function (controllers) {
var ExampleController = (function () {
function ExampleController() {
}
return ExampleController;
})();
controllers.ExampleController = ExampleController;
})(wctApp.controllers || (wctApp.controllers = {}));
var controllers = wctApp.controllers;
})(wctApp || (wctApp = {}));
var wctApp;
(function (wctApp) {
(function (controllers) {
var ExampleController = (function () {
function ExampleController() {
}
return ExampleController;
})();
controllers.ExampleController = ExampleController;
})(wctApp.controllers || (wctApp.controllers = {}));
var controllers = wctApp.controllers;
})(wctApp || (wctApp = {}));
;
var newExample = new wctApp.controllers.ExampleController();