问题
I have a config file throwing error when only building with AOT ionic cordova build android --prod
Error: ./src/config/.env.ts Module build failed: TypeError: Cannot read property 'content' of undefined at Object.optimizationLoader (/Users/yasir/myApp/mobile/node_modules/@ionic/app-scripts/dist/webpack/optimization-loader-impl.js:14:24) at Object.loader (/Users/yasir/myApp/mobile/node_modules/@ionic/app-scripts/dist/webpack/optimization-loader.js:5:32) @ ./src/providers/post-service.js 15:0-40 @ ./src/app/app.module.ngfactory.js @ ./src/app/main.ts
This is the content of the .env.ts
file. The file is inside src .src/config/.env.ts
export const config: any = {
serverUrl: "http://0.0.0.0:3000"
};
回答1:
It seems that on production build, its skipped files containing dot
.env
.. so I removed the dot env
and everything got back to normal
来源:https://stackoverflow.com/questions/45808908/typeerror-cannot-read-property-content-of-undefined