0

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!

Shown
  • 31
  • 4
  • i find that `workbook.xlsx.writeBuffer().then((data) => console.log(1))` i did not print 1 in console. – Shown Sep 29 '19 at 09:35

1 Answers1

1

solved:

use

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

instead of

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

Shown
  • 31
  • 4
  • That is interesting. Don't use the min file because prod mode would try and min it again is what it looks like. – edjm Aug 18 '22 at 17:43