bower-webpack-plugin icon indicating copy to clipboard operation
bower-webpack-plugin copied to clipboard

How to resolve a css file in bower_components

Open lovedota opened this issue 11 years ago • 3 comments

Hi friends. Please help me with this. I try to use BowerWebpack for looking for bower_components, but it seems get only js file, how about css file. Thanks !

require('select2.css'); //This line is not work
require('select2'); //this line work as expect

lovedota avatar Apr 23 '15 06:04 lovedota

Try adding .css to resolve.extensions in your webpack config.

ypomortsev avatar Jun 15 '15 20:06 ypomortsev

@illicium I tried extensions: ['', '.webpack.js', '.web.js', '.js', '.css'], but it does not work.

require('select2.css'); //This line for loading css file
require('select2'); //this line automatically load js file

Thanks !

lovedota avatar Jun 16 '15 09:06 lovedota

@lovedota BowerWebpackPlugin will try to load all files specified in the component's bower.json main section. select2 references an SCSS stylesheet, but webpack can't load it out of the box -- you'll need to install sass-loader.

Alternatively, you can manually require the precompiled CSS file by specifying the path relative to the bower component:

require('select2/dist/css/select2.css');

ypomortsev avatar Jun 16 '15 18:06 ypomortsev