Visual studio cordova Visual Studio Cordova排除文件 使用默认设置和空白Type脚本项目,生成过程包括Apk/XAP\WWW DIR中包括D.TS和.TS文件的项目目录中的所有文件。除了编辑vs mda文件外,是否有一种方法可以全局(而不是ant.properties等)从打包中排除文件,同时维护intellisense并将.ts文件编译到正确的位置
另一个方面是,ionic和angular nuget软件包将xxx.js和xxx.min.js安装到\scripts目录中,并最终安装到apk/xap中Visual studio cordova Visual Studio Cordova排除文件 使用默认设置和空白Type脚本项目,生成过程包括Apk/XAP\WWW DIR中包括D.TS和.TS文件的项目目录中的所有文件。除了编辑vs mda文件外,是否有一种方法可以全局(而不是ant.properties等)从打包中排除文件,同时维护intellisense并将.ts文件编译到正确的位置,visual-studio-cordova,Visual Studio Cordova,另一个方面是,ionic和angular nuget软件包将xxx.js和xxx.min.js安装到\scripts目录中,并最终安装到apk/xap中 我正在寻找一种可以在项目模板中正确使用的方法来打包.vsix模板发行版,而无需最终用户进行大量手动编辑。不幸的是,在VS2013 CTP3.1中实现这一点的唯一方法是在自定义插件中创建Cordova挂钩。钩子可以附加到after_prepare事件,然后您可以编写代码从“bld”下生成的“platforms”文件夹中的正确位置删除文件 请参见此
我正在寻找一种可以在项目模板中正确使用的方法来打包.vsix模板发行版,而无需最终用户进行大量手动编辑。不幸的是,在VS2013 CTP3.1中实现这一点的唯一方法是在自定义插件中创建Cordova挂钩。钩子可以附加到after_prepare事件,然后您可以编写代码从“bld”下生成的“platforms”文件夹中的正确位置删除文件 请参见此处的插件删除类型脚本: hook-remove-ts.js:
module.exports = function (context) {
var fs = require("fs");
var glob = context.requireCordovaModule('glob');
context.opts.cordova.platforms.forEach(function(platform) {
console.log("Processing " + platform);
// Get all TS files under platforms folder
glob("platforms/" + platform + "/**/*.ts", function(err, tsFiles) {
if(err) throw err;
tsFiles.forEach(function(tsFile) {
console.log("Deleting " + tsFile);
fs.unlinkSync(tsFile);
});
});
});
}
要安装它,只需从Git repo中的plugin remove typescript文件夹中抓取它,并将其放到本地文件夹中。使用配置设计器的“自定义”选项卡选择它。您还可以通过更新插件()中的glob语法来修改它以删除其他文件类型
随着VS 2015即将发布,这种情况将得到改善
关于Cordova钩子的更多信息:好的,考虑到Chuck Lantz提供的框架,我编写了一个插件来删除.ts和一些杂乱的文件。它还可以在同一目录中存在缩小版本时删除未统一的js/css(如果需要,可以添加一个开关来关闭它),并提供一种机制,在发布版本中全局排除文件模式,并在每个目录的基础上排除,而无需编辑插件。从0.8.6起递归排除目录 在我正在开发的应用程序上,它减少了75%~5MB->~1MB
@Chuck Lantz answer几年前确实帮助了我。 从那时起,科尔多瓦就开始发展。 我尝试使用cordova插件排除文件(,)。看起来不错,但是:
function updateWwwFrom(cordovaProject, destinations) {
// use per OS EOL symbol
var endOfLine = require('os').EOL;
// build whitelist file path
var includeFile = path.join(cordovaProject.root, 'build-include.txt');
// verbosing (will appear in Visual Studio output pane)
events.emit('verbose', 'Copying files listed in ' + includeFile );
// read the whitelist file
var files = require('fs').readFileSync(includeFile, 'utf-8').split(endOfLine);
// ORIGINAL // clear destination www dir
shell.rm('-rf', destinations.www);
// ORIGINAL // create destination www dir
shell.mkdir('-p', destinations.www);
// ORIGINAL // Copy source files from project's www directory
// ORIGINAL shell.cp('-rf', path.join(cordovaProject.locations.www, '*'), destinations.www);
// copy files from whitelist
files.forEach( item => copyToWWW( path.join(cordovaProject.locations.www, item) , destinations.www, path.dirname(item)));
// ORIGINAL // Override www sources by files in 'platform_www' directory
shell.cp('-rf', path.join(destinations.platformWww, '*'), destinations.www);
// ORIGINAL // If project contains 'merges' for our platform, use them as another overrides
var merges_path = path.join(cordovaProject.root, 'merges', 'android');
if (fs.existsSync(merges_path)) {
events.emit('verbose', 'Found "merges" for android platform. Copying over existing "www" files.');
var overrides = path.join(merges_path, '*');
shell.cp('-rf', overrides, destinations.www);
}
}
// copy files from whitelist
function copyToWWW(source, dest, dirname)
{
var destWithDirName = path.join(dest, dirname);
shell.mkdir('-p', destWithDirName);
shell.cp('-rf', source, destWithDirName );
}
新增辅助功能:
function updateWwwFrom(cordovaProject, destinations) {
// use per OS EOL symbol
var endOfLine = require('os').EOL;
// build whitelist file path
var includeFile = path.join(cordovaProject.root, 'build-include.txt');
// verbosing (will appear in Visual Studio output pane)
events.emit('verbose', 'Copying files listed in ' + includeFile );
// read the whitelist file
var files = require('fs').readFileSync(includeFile, 'utf-8').split(endOfLine);
// ORIGINAL // clear destination www dir
shell.rm('-rf', destinations.www);
// ORIGINAL // create destination www dir
shell.mkdir('-p', destinations.www);
// ORIGINAL // Copy source files from project's www directory
// ORIGINAL shell.cp('-rf', path.join(cordovaProject.locations.www, '*'), destinations.www);
// copy files from whitelist
files.forEach( item => copyToWWW( path.join(cordovaProject.locations.www, item) , destinations.www, path.dirname(item)));
// ORIGINAL // Override www sources by files in 'platform_www' directory
shell.cp('-rf', path.join(destinations.platformWww, '*'), destinations.www);
// ORIGINAL // If project contains 'merges' for our platform, use them as another overrides
var merges_path = path.join(cordovaProject.root, 'merges', 'android');
if (fs.existsSync(merges_path)) {
events.emit('verbose', 'Found "merges" for android platform. Copying over existing "www" files.');
var overrides = path.join(merges_path, '*');
shell.cp('-rf', overrides, destinations.www);
}
}
// copy files from whitelist
function copyToWWW(source, dest, dirname)
{
var destWithDirName = path.join(dest, dirname);
shell.mkdir('-p', destWithDirName);
shell.cp('-rf', source, destWithDirName );
}
并在我的项目根目录中创建build-include.txt文件。样本内容:
subdir/*
subdir2/file.png
非常感谢。你肯定让我朝着正确的方向前进。我将发布我添加到其中的内容,以最大限度地清理爱奥尼亚应用程序!尽管您可能希望在plugin.xml中更新此部分->