I'm trying to incorporate my process.env variable into the webpack Bundle using DefinePlugin. Here's the snippet of code in my webpack config:
plugins: [
new webpack.DefinePlugin({
'process.env': JSON.stringify(process.env)
}),
ionicWebpackFactory.getIonicEnvironmentPlugin(),
ionicWebpackFactory.getCommonChunksPlugin()
],
In my package.json file, I have the following configuration:
"@ionic/app-scripts": "3.1.9",
"@types/jasmine": "^2.8.6",
"@types/node": "^9.6.6",
...
"html-loader": "^0.5.5",
....
"null-loader": "^0.1.1",
"ts-loader": "^4.0.0",
"ts-node": "^6.0.0",
"tslint": "^5.9.1",
"tslint-eslint-rules": "^5.1.0",
"typescript": "~2.6.2",
"webpack": "^4.6.0"
},
"config": {
"ionic_webpack": "./config/webpack.config.js"
},
I have a service that utilizes the process.env injected by the plugin:
import { Injectable } from '@angular/core';
declare var process: {
env: any
};
@Injectable()
export class ConfigurationService {
However, when I compile using yarn or npm, I encounter the following error:
[10:28:04] ionic-app-script task: "build"
[10:28:04] TypeError: Cannot read property 'compilation' of undefined
TypeError: Cannot read property 'compilation' of undefined
at DefinePlugin.apply ...\node_modules\webpack\lib
\DefinePlugin.js:42:18)
at Compiler.apply ( ...\node_modules\tapable\lib\Tapable.js:375:16)
I've searched online for a solution but couldn't find a similar issue. Thank you for your assistance.
Julien.