codevise / activeadmin-searchable_select

Searchable select boxes for forms and filters
Other
97 stars 33 forks source link

Error with cssbundling: Can't find stylesheet to import @import "select2" #52

Open fvue opened 3 months ago

fvue commented 3 months ago

searchable_select.scss-1.8.0 does not work with cssbundling gem because @codevise/activeadmin-searchable_select/src/searchable_select.scss does an '@import "select2"' which should be spelled out with cssbundling (see: https://github.com/rails/cssbundling-rails): @import "select2/dist/css/select2";

Workaround is not to include the vendor '@codevise/activeadmin-searchable_select/src/searchable_select.scss' in your active_admin.scss, but instead copy the contents of @codevise/activeadmin-searchable_select/src/searchable_select.scss in your active_admin.scss:

app/assets/stylesheets/active_admin.scss

//---8<------------------------------------------------------------------- // NOTE: searchable_select.scss-1.8.0 does not work because it does an '@import "select2"' // which should be spelled out: @import "select2/dist/css/select2"; // @import '@codevise/activeadmin-searchable_select/src/searchable_select.scss';

@import "select2/dist/css/select2";

.searchable_select.input .select2-container { min-width: 30%; } //---8<------------------------------------------------------------------

tf commented 2 months ago

I'd be open to a PR that rewrites the import statement when we prepare the stylesheet for the published npm package. The file in app/assets/stylesheets would still need the unaltered import to keep the asset pipeline case working since there we import from the select2-rails gem which has a different internal structure.