mare
mare

Reputation: 13083

Where are Angular's webpack bundles configured?

With the default new Angular CLI based project and it's webpack integration some things are weird. Where are the default bundles configured?

I removed the styles.css file now the project doesn't build.

chunk {inline} inline.bundle.js, inline.bundle.js.map (inline) 5.83 kB [entry] [rendered]chunk {main} main.bundle.js, main.bundle.js.map (main) 303 bytes [initial] [rendered]
chunk {polyfills} polyfills.bundle.js, polyfills.bundle.js.map (polyfills) 323 bytes [initial] [rendered]
chunk {styles} styles.bundle.js, styles.bundle.js.map (styles) 342 bytes [initial] [rendered]

ERROR in multi ./src/styles.css
Module not found: Error: Can't resolve 'D:\project\src\styles.css' 

Upvotes: 0

Views: 42

Answers (2)

Kirk Larkin
Kirk Larkin

Reputation: 93073

The Angular CLI provides configurations options using .angular-cli.json. This has a defined schema that defines the options that can be configured. As the Angular CLI wraps up Webpack for you, you can't get direct access to the Webpack config itself when using the Angular CLI. You have a couple of options:

  1. Change the relevant settings in .angular-cli.json, if they fit.
  2. Use ng eject on your project:

    ng eject ejects your app and output the proper webpack configuration and scripts.

    Once ejected, you can modify the Webpack configuration accordingly.

In order to fix your specific issue with styles.css, you can just go with option 1 and update .angular-cli.json to exclude this file - It's essentially specified under apps[0].styles, which defaults to an array with a single element: styles.css.

Upvotes: 1

Poul Kruijt
Poul Kruijt

Reputation: 71911

Inside your .angular-cli.json file there is still a reference to the styles.css. Remove the entry from apps.styles as well, and it won't throw an error anymore

Upvotes: 1

Related Questions