Search code examples
webpackminifywebpack-dev-serverprimeng

PrimeNG + Webpack


I just want to share my experience with the issue where many warnings like the one below appear when using PrimeNG and Webpack.

WARNING in ../MyProjectName/~/primeng/components/orderlist/orderlist.js
Cannot find source file '../../src/app/components/orderlist/orderlist.ts': Error: C               an't resolve '../../src/app/components/orderlist/orderlist.ts' in '...MyProjectName\node_modules\primeng\components\orderlist'
 @ ../MyProjectName/~/primeng/primeng.js 50:9-52

...

This is a problem with the hardcoded route in all source mappings of primeng components.


Solution

  • The solution is to exclude node_modules\primeng in your webpack.config.js:

        "enforce": "pre",
        "test": /\.js$/,
        "loader": "source-map-loader",
        "exclude": [
                    /\/node_modules\//,
                    path.join(process.cwd(), "node_modules\\primeng"),
         ]