The HTML starter kit pro for Durandal contains the following grunt task for optimizing a build:
durandal: {
main: {
src: ['app/**/*.*', 'lib/durandal/**/*.js'],
options: {
name: '../lib/require/almond-custom',
baseUrl: requireConfig.baseUrl,
mainPath: 'app/main',
paths: mixIn({}, requireConfig.paths, {
'almond': '../lib/require/almond-custom.js'
}),
exclude: [],
optimize: 'none',
out: 'build/app/main.js'
}
}
}
I have some concerns about it which I need your help sorting out:
Script file redundancy. The build process keeps the
libfolder with scripts like jQuery, bootstrap etc. Why? If you look at the builtbuild/app/main.jsis has added all those scripts. Which leads me to the following question:If I remove the
libfolder, everything works, except for the fact that I get arequire is not definedin the console. The code still looks forlib/require/require.jswhich can be solved by simply adding it there. However, isn't this whatalmondis all about? It's included in the builtbuild/app/main.jsfile. As far as I knew, Almond is a light weight replacement for require to be used in optimized files.
To reproduce the issues you can simply run the "Quick start" provided in the link at the top.
Yes, You are right that
main.jsincludes everything needed to run the app. The reason You are gettingrequire is not definedis because, if you closely look at theindex.htmlfile you will see that theindex.htmlrefers looks for the file in/lib/requirefolder and loads ourmain.jsfile through it. there is another line right below that inindex.htmlwhich is commented, you can just uncomment that and it should just work even if you removelibdirectory.The only errros that you will get by removing the
/libdirectory after uncommenting<script src="app/main.js"></script>line and commenting<script src="lib/require/require.js" data-main="app/main"></script>.Hope it helps.