I am building an application with angular 2, sass and webpack, and I am having problems with the url on the sass files that are required inside each component (using require); it does not accept these files and does not copy them to the resource folder and does not change the URL for the constructed CSS styles. It works correctly when I use import and with assets inside html components.
loaders:
...{ test: /\.html$/, loader: 'html' }, { test: /\.(png|jpe?g|gif)$/, loader: 'file?name=assets/[name].[hash].[ext]' }, { test: /\.scss/, exclude: helpers.root('src', 'app'), loader: ExtractTextPlugin.extract('style', 'css?sourceMap!sass?sourceMap') }, { test: /\.scss$/, include: helpers.root('src', 'app'), loaders: ['raw', 'resolve-url', 'sass?sourceMap'] }...
Require styles:
... styles: [require('./hero-image.scss')] template: require('./hero-image.component.html') ...
Sass
... background: url('../../../public/img/hero-bg.jpg'); ...
Here, the loaders (during assembly) should copy hero-bg.jpg to / assets /, and the background css built should have /assets/hero-bg.jpg , but it does not copy the image to folders with resources, and css builded remains as an audacity .
NOTE. . When I use import instead of the required one (changing the loader rules, of course), at the moment it works correctly. Inside the html component (hero-image.component.html) I have this <img src="../../../public/img/btn-google-play.jpg" /> , and it works correctly too .
I am trying to use this angular 2 starter pack , and a problem also occurs.
Thanks for the help, I really appreciate it.
Edit: I forgot to mention that this also happens using only css (without sass) and after the official angular documentation about the web package
angular sass webpack requirejs
David Velásquez Usuga
source share