Skip to content

Commit

Permalink
feat(conf): improve+update custom webpack configuration (azerothcore#…
Browse files Browse the repository at this point in the history
  • Loading branch information
FrancescoBorzi authored Nov 14, 2021
1 parent 92c2588 commit b71c49c
Show file tree
Hide file tree
Showing 8 changed files with 13,736 additions and 21,706 deletions.
32 changes: 27 additions & 5 deletions angular.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
"options": {
"customWebpackConfig": {
"allowedCommonJsDependencies": ["highlight.js", "squel", "sqlstring"],
"path": "./extra-webpack.config.js"
"extractCss": true,
"path": "./angular.webpack.js"
},
"aot": true,
"outputPath": "dist",
Expand Down Expand Up @@ -43,7 +44,6 @@
"optimization": false,
"outputHashing": "all",
"sourceMap": true,
"extractCss": true,
"namedChunks": false,
"aot": false,
"extractLicenses": true,
Expand All @@ -56,6 +56,22 @@
}
]
},
"dev-web": {
"optimization": false,
"outputHashing": "all",
"sourceMap": true,
"namedChunks": false,
"aot": false,
"extractLicenses": true,
"vendorChunk": false,
"buildOptimizer": false,
"fileReplacements": [
{
"replace": "src/environments/environment.ts",
"with": "src/environments/environment.web.ts"
}
]
},
"production": {
"budgets": [
{
Expand All @@ -66,7 +82,6 @@
"optimization": true,
"outputHashing": "all",
"sourceMap": false,
"extractCss": true,
"namedChunks": false,
"aot": true,
"extractLicenses": true,
Expand All @@ -90,6 +105,9 @@
"dev": {
"browserTarget": "Keira3:build:dev"
},
"dev-web": {
"browserTarget": "angular-electron:build:dev-web"
},
"production": {
"browserTarget": "Keira3:build:production"
}
Expand All @@ -102,7 +120,7 @@
}
},
"test": {
"builder": "@angular-devkit/build-angular:karma",
"builder": "@angular-builders/custom-webpack:karma",
"options": {
"main": "src/test.ts",
"polyfills": "src/polyfills-test.ts",
Expand All @@ -126,7 +144,11 @@
"src/favicon.icns",
"src/favicon.256x256.png",
"src/favicon.512x512.png"
]
],
"customWebpackConfig": {
"path": "./angular.webpack.js",
"target": "web"
}
}
},
"lint": {
Expand Down
28 changes: 28 additions & 0 deletions angular.webpack.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/**
* Custom angular webpack configuration
*/

module.exports = (config, options) => {
config.target = 'electron-renderer';
if (options.customWebpackConfig.target) {
config.target = options.customWebpackConfig.target;
} else if (options.fileReplacements) {
for (let fileReplacement of options.fileReplacements) {
if (fileReplacement.replace !== 'src/environments/environment.ts') {
continue;
}

let fileReplacementParts = fileReplacement['with'].split('.');
if (['dev', 'prod', 'test', 'electron-renderer'].indexOf(fileReplacementParts[1]) < 0) {
config.target = fileReplacementParts[1];
}
break;
}
}

config.externals = {
sqlite3: 'commonjs sqlite3',
};

return config;
};
5 changes: 0 additions & 5 deletions extra-webpack.config.js

This file was deleted.

Loading

0 comments on commit b71c49c

Please sign in to comment.