Johan
Johan

Reputation: 35223

Excluding file from optimizing in Durandal build

I'm using Grunt to build the Durandal starter kit pro package.

It all works fine, except for one tiny detail. I would like to exclude one file (app-config below) from the optimizer and keep it as a non minified file when my build is done.

Based on other SO thread suggestions, I'm currently excluding it using empty:, which removes it from the optimized file as expected. However, when I open the built project I get an error in the console:

Uncaught Error: main missing app-config

options: {
    name: '../lib/require/almond-custom',
    baseUrl: requireConfig.baseUrl,
    mainPath: 'app/main',
    paths: mixIn({ }, requireConfig.paths, { 
         'almond': 'lib/require/almond-custom', 
         'app-config': 'empty:' 
    }),
    optimize: 'none',
    out: 'build/app/main.js',
    preserveLicenseComments: false
}

Is almond the problem? I tried switching it to the full requirejs using include: ['path/to/require'], without success.

If you want to reproduce it locally you can either download the starter kit from the above link, or use a slightly configurated version which is closer to my example. Just run an npm install in the folder and you're all set.

Upvotes: 6

Views: 213

Answers (3)

T.Todua
T.Todua

Reputation: 56557

try:

....
paths: mixIn({ }, requireConfig.paths, { 
     'almond': ['lib/require/almond-custom', '!lib/require/almond-custom/app-config.js']
}),
....

just note the second path of app-config.js is correct. I think you should find your way, the above is a hint, if not a direct solution.

Upvotes: 0

Pritish Vaidya
Pritish Vaidya

Reputation: 22209

From the reference of the durandal issues found in this particular link grunt-durandal

The main module controls the implementation of the durandal services The link can be found in main.js

Here you can see the system.debug(true).You can remove it as written in the post here document.

The function as quoted in the article Overrides request execution timeout making it effectively infinite.

Also while using uglify in grunt the debug is set to false as per the documentation.

As per the documentation you need to set the system.debug(false)

Hope this might help a bit.

Upvotes: 0

trungvose
trungvose

Reputation: 20034

I have downloaded you source code and do the following steps.

  1. Extract zip file, open cmd and change the directory to this folder.
  2. Run npm install to install all the dependencies.
  3. Run grunt to start to build the project.

And when I open http://localhost:8999/ and saw the alert 1 which is alert(appConfig.foo); in your main.js. After clicked Ok to hide the alert, the web page works fines. Any more input for you ?

First step

Second step

So I am not sure how you are facing with this issue.

Upvotes: 3

Related Questions