Skip to content

Commit 89c11c4

Browse files
committed
Add missing webpack exports
Add some entries to `package.json` to improve compatibility with webpack - Add default `style` and `sass` exports as per webpack requirements - Add `styles/*` exports for CSS files - Add `scss/styles/*` exports for Scss files - Add `*.scss` and `*.css` to "side effects" to prevent issues with tree-shaking With this commit, it is possible to import the style with the following approaches: ```js import "choices.js/styles/choices.css"; // CSS import "choices.js/scss/styles/choices.scss"; // Scss ``` ```scss @import "choices.js/scss/styles/choices"; ``` Refs: - https://webpack.js.org/guides/package-exports/ Close Choices-js#1184
1 parent 1801a04 commit 89c11c4

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

package.json

+10-3
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@
1212
".": {
1313
"types": "./public/types/src/index.d.ts",
1414
"import": "./public/assets/scripts/choices.mjs",
15-
"require": "./public/assets/scripts/choices.js"
15+
"require": "./public/assets/scripts/choices.js",
16+
"style": "./public/assets/styles/choices.css",
17+
"sass": "./src/styles/choices.scss"
1618
},
1719
"./search-basic": {
1820
"types": "./public/types/src/index.d.ts",
@@ -23,9 +25,14 @@
2325
"types": "./public/types/src/index.d.ts",
2426
"import": "./public/assets/scripts/choices.search-none.mjs",
2527
"require": "./public/assets/scripts/choices.search-none.min.js"
26-
}
28+
},
29+
"./scss/styles/*": "./src/styles/*.scss",
30+
"./styles/*": "./public/assets/styles/*.css"
2731
},
28-
"sideEffects": false,
32+
"sideEffects": [
33+
"*.scss",
34+
"*.css"
35+
],
2936
"scripts": {
3037
"start": "run-p js:watch css:watch",
3138
"build": "run-p js:build css:build",

0 commit comments

Comments
 (0)