Search code examples
angularexceljs

can not download file when set optimization=true in angular.json file


I am using exceljs and file-saver.js in my project, and it worked fine in my dev environment, but when i build in prod env, i could not download file anymore, does anyone help me?

When i set optimization=false in prod configuration, it worked fine.

angular.json

"configurations": {
        "production": {
           "fileReplacements": [
                 {
                    "replace": "src/environments/environment.ts",
                    "with": "src/environments/environment.prod.ts"
                 }
                ],
            "optimization": true,
            "outputHashing": "all",
            "sourceMap": false,
            "extractCss": true,
            "namedChunks": false,
            "aot": true,
            "extractLicenses": true,
            "vendorChunk": false,
            "buildOptimizer": true
        },
        "dev": {
            "fileReplacements": [
                 {
                    "replace": "src/environments/environment.ts",
                    "with": "src/environments/environment.dev.ts"
                  }
               ]
            }
        }

i want to know:

  1. how to fix this problem? i think the config 'optimization' should be 'true';

2.if i set the optimization=false, what will happen?

Thanks very much!


Solution

  • solved:

    use

    import {Woekbook} from 'exceljs/dist/exceljs.js';

    instead of

    import {Woekbook} from 'exceljs/dist/exceljs.min.js';