angular-builders: when I updated to version 8, the custom loader could not execute

In version 7, it can execute docs-loader.js and print docs loader is called!, but when I updated to version 8, the custom loader could not execute.

package.json:

"devDependencies": {
        "@angular-builders/custom-webpack": "^8.1.0",
        "@angular-devkit/build-angular": "^0.801.0",
        "@angular-devkit/build-ng-packagr": "^0.801.0",
        "@angular/cli": "^8.1.0"
    }

angular.json:

{
    "$schema": "./node_modules/@angular/cli/lib/config/schema.json",
    "version": 1,
    "newProjectRoot": "",
    "projects": {
        "demo": {
            "root": "",
            "sourceRoot": "demo/src",
            "projectType": "application",
            "prefix": "demo",
            "schematics": {},
            "architect": {
                "build": {
                    "builder": "@angular-builders/custom-webpack:browser",
                    "options": {
                        "customWebpackConfig": {
                            "path": "extra-webpack.config.js"
                        },
                        "indexTransform": "index-html-transform.js",
                        "outputPath": "docs",
                        "index": "demo/src/index.html",
                        "main": "demo/src/main.ts",
                        "polyfills": "demo/src/polyfills.ts",
                        "tsConfig": "demo/tsconfig-app.json",
                        "assets": [],
                        "styles": [
                            "node_modules/bootstrap-less/bootstrap/index.less",
                            "node_modules/prismjs/themes/prism.css",
                            "node_modules/prismjs/plugins/line-numbers/prism-line-numbers.css",
                            "demo/src/styles.less"
                        ],
                        "scripts": [
                            "node_modules/focus-visible/dist/focus-visible.min.js"
                        ]
                    },
                    "configurations": {
                        "production": {
                            "fileReplacements": [
                                {
                                    "replace": "demo/src/environments/environment.ts",
                                    "with": "demo/src/environments/environment.prod.ts"
                                }
                            ],
                            "optimization": true,
                            "outputHashing": "all",
                            "sourceMap": false,
                            "extractCss": true,
                            "namedChunks": false,
                            "aot": true,
                            "extractLicenses": true,
                            "vendorChunk": false,
                            "buildOptimizer": true,
                            "budgets": [
                                {
                                    "type": "initial",
                                    "maximumWarning": "2mb",
                                    "maximumError": "5mb"
                                }
                            ]
                        }
                    }
                },
                "serve": {
                    "builder": "@angular-builders/custom-webpack:dev-server",
                    "options": {
                        "browserTarget": "demo:build"
                    },
                    "configurations": {
                        "production": {
                            "browserTarget": "demo:build:production"
                        }
                    }
                }
            }
        }
    },
    "defaultProject": "demo"
}

extra-webpack.config.js:

const helper = require('./tools/helper');

module.exports = {
    module: {
        rules: [
            {
                test: /\.(htm|html)$/,
                loader: helper.root('tools/docs/docs-loader.js'),
                include: [helper.root('demo/src')]
            }
        ]
    }
};

docs-loader.js (simplified version):

module.exports = function (source) {
    console.log('docs loader is called!');
    return source;
};

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Comments: 24 (13 by maintainers)

Most upvoted comments