Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 818
Johan Avatar asked Oct 06 '16 07:10

Johan


1 Answers

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.

like image 52
trungk18 Avatar answered Oct 19 '22 23:10

trungk18