问题
i set up a post-build event in visual studio to use durandal's optimizer (which uses nodejs) to build the main-built.js file for production. getting an error saying it can't find main-built.js. i believe this is because it's not referencing my project properly. my base directory is at c:\projects\myapp\myapp. it's only looking for the durandal directory from c:\projects\myapp.
is there a way to tell it the correct directory?
here's some of the output.
if 'Release'=='Release' C:\Projects\myapp\myapp\\App\durandal\amd\optimizer.exe
Using default base configuration.
Configuring for deploy with almond (custom).
{
"name": "durandal/amd/almond-custom",
"inlineText": true,
"stubModules": [
"durandal/amd/text"
],
"paths": {
"text": "durandal/amd/text"
},
"baseUrl": "C:\\Projects\\myapp",
"mainConfigFile": "C:\\Projects\\myapp\\main.js",
"include": [
"packages/Durandal.1.1.0/content/App/durandal/app",
...etc...
],
"exclude": [],
"keepBuildDir": true,
"optimize": "uglify2",
"out": "C:\\Projects\\myapp\\main-built.js",
"pragmas": {
"build": true
},
"wrap": true,
"insertRequire": [
"main"
]
}
回答1:
i found out that even tho it's pointing to the wrong place, i can change it by using the --source attribute on optimizer.
the fix was to use the source attribute and point it to the base directory of the durandal files in the post-build event.
in my case, it looked like this:
if '$(Configuration)'=='Release' $(ProjectDir)\App\durandal\amd\optimizer.exe --source c:\projects\myapp\myapp\app
'app' being the root of the durandal files and folders.
来源:https://stackoverflow.com/questions/15684040/durandal-optimizer-references-wrong-path-when-building-it-as-a-post-build-proces