question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

when I updated to version 8, the custom loader could not execute

See original GitHub issue

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;
};

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:24 (13 by maintainers)

github_iconTop GitHub Comments

1reaction
laixiangrancommented, Jul 31, 2019

I created two minimal replication repos, corresponding to version 7 and version 8: https://github.com/laixiangran/angular-builders-demo/tree/7.0.0 https://github.com/laixiangran/angular-builders-demo/tree/8.0.0

0reactions
matheocommented, Nov 7, 2021

For the record, I leave here the Typescript that worked out for Angular 12 😄

import { AngularWebpackPlugin } from '@ngtools/webpack';
import { Configuration } from 'webpack';

export default (config: Configuration): Configuration => {
  const index = config.plugins.findIndex(p => p instanceof AngularWebpackPlugin);
  const options = (config.plugins[index] as AngularWebpackPlugin).options;
  options.directTemplateLoading = false;
  config.plugins.splice(index, 1, new AngularWebpackPlugin(options));

  config.module.rules.push({
    test: /\.pug$/,
    use: [
      { loader: require.resolve('raw-loader') },
      { loader: require.resolve('pug-plain-loader') },
    ],
  });

  config.resolve.fallback = {
    stream: require.resolve('stream-browserify'),
  };

  return config;
};
Read more comments on GitHub >

github_iconTop Results From Across the Web

Error: PostCSS plugin autoprefixer requires ... - Stack Overflow
PostCSS was updated to version 8, however, PostCSS CLI has not yet been updated to handle PostCSS plugins which use the new PostCSS...
Read more >
Known Issues for JDK 8 - Oracle
This document describes known issues in the Oracle JDK 8 release.
Read more >
sass-loader - npm
The sass-loader uses Sass's custom importer feature to pass all queries to the Webpack resolving engine. Thus you can import your Sass modules ......
Read more >
Known issues with Android Studio and Android Gradle Plugin
To fix this issue, upgrade your Android 11 emulator to version 9 or higher by navigating to Tools > SDK Manager. In the...
Read more >
Windows Installer Error Messages (for Developers)
A script required for this install to complete could not be run. Contact your support personnel or package vendor. Custom action [2] script ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found