How to use choices.js on webpack?
See original GitHub issueI’m using webpack
.
./node_modules/.bin/webpack -v
3.5.2
I tried choices.js. However happend build error. It is because svg file can not found.
// resources/css/admin/app.css
@import "choices.js/assets/styles/css/choices.css";
$ webpack
ERROR in ./resources/css/admin/app.css
Module not found: Error: Can't resolve '../../icons/cross-inverse.svg' in '/Users/orange-lion/**/resources/css/admin'
@ ./resources/css/admin/app.css 6:150116-150156
ERROR in ./resources/css/admin/app.css
Module not found: Error: Can't resolve '../../icons/cross.svg' in '/Users/orange-lion/**/resources/css/admin'
@ ./resources/css/admin/app.css 6:151469-151501
I know that it will work if it is an absolute path.
.choices[data-type*="select-one"] .choices__button {
background-image: url("/assets/icons/cross-inverse.svg");
padding: 0;
...
}
This code will not faild to build.
But, it is to edit directly node_modules/choices.js/assets/styles/css/choices.css
I don’t want to do it.
Are you have any good idea?
[Edit] Can copy that file, but that is not a good solution. Because it will not keep up with the version upgrade.
Issue Analytics
- State:
- Created 6 years ago
- Reactions:3
- Comments:8 (4 by maintainers)
Top Results From Across the Web
How to import Choices.js into webpack 4? - Stack Overflow
I am trying to import the module Choices.js into webpack. My entry file (app.js): enter image description here; My package.json enter image ...
Read more >How to use choices.js on webpack? · Issue #223 - GitHub
I'm using webpack. ./node_modules/.bin/webpack -v 3.5.2 I tried choices.js. ... I know that it will work if it is an absolute path.
Read more >Choices
Choices.js is a lightweight, configurable select box/text input plugin. Similar to Select2 and Selectize but without the jQuery dependency.
Read more >3 Dependencies - choices.js - npm
Start using choices.js in your project by running `npm i choices.js`. There are 159 other projects in the npm registry using choices.js.
Read more >Choices.js - Best of JS
This is useful if you have a lot of choices where it is easier for a user to use the search area to...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Overwrite the icon path prior to import:
Coincidentally, you need to do something similar for font-awesome:
I fixed this issue by using
svg-url-loader
with this is webpack config:This will inline the cross.svg image as base64.
Also you have to @import the
choices.css
Later Edit:
Upon rereading, you issue might be different… I fixed that issue by using
@import (less)
instead of@import (inline)
, but I use less… so this won’t work for everyone.