We pack icon-font files along with our w-components NPM module, then let the users decide if they are going to import them either by JS import (with Webpack) or manually (with vanilla JS).
Changes in Detail
1. Add a icon-font CSS file for outside project to easily import.
(The CSS import was supposed to be imported as a side effect. However a named import & export was seemed to be needed for being detected used and then bundled by Webpack. Wierd...)
3. After Webpack bundling, the icon-font files will be outputed as separated files, and the related @font-face CSS will be bundled within the JS file.
When we run the official site, the @font-face CSS will be automatically inserted as <style> tag into HTML.
Solution In a Nutshell
We pack icon-font files along with our
w-components
NPM module, then let the users decide if they are going to import them either by JS import (with Webpack) or manually (with vanilla JS).Changes in Detail
1. Add a icon-font CSS file for outside project to easily import. (The CSS import was supposed to be imported as a side effect. However a named import & export was seemed to be needed for being detected used and then bundled by Webpack. Wierd...)
2. Add Webpack modules to parse & bundle CSS & TTF files
3. After Webpack bundling, the icon-font files will be outputed as separated files, and the related
@font-face
CSS will be bundled within the JS file. When we run the official site, the@font-face
CSS will be automatically inserted as<style>
tag into HTML.