The w-components package is moved under packages folder.
The other codes related to official site are remained in the root.
Introduce Webpack
To use modules installed in .node_modules, we need to use Webpack to bundle them to one single JS file.
To import the bundled JS file, we need to output the bundle in the format of ES6 module. This topic was discuss in #59 before and gave up then for their internal support issue. The feature is still in experiment, but looks good enough for our use now.
Usage
Local setup
In the root directory:
a. Install packages
npm install
b. Build bundle
npm run build
c. Visit index.html with live server
Publish to GitHub page
Simply build bundle as above and push to git, everything should be done.
Known Issues to be Solved
As using NPM for package management, I changed highlight.js dependency from local to npm module. However I tried different Webpack configs, this package would always be included and caused the bundle oversized (almost 1MB.)
Should keep trying, or just fallback to local files otherwise.
With Webpack bundling system, now we lose the hot-reload feature.
Introduce webpack-dev-server plugin maybe, so that the codes could be auto re-build on source file changes.
Environment Requirements
Make sure your node.js runtime version is:
>= 12
: for ES6 module support< 17
: for avoiding known issueMajor Adjustments
Introduce NPM workspaces
w-components
package is moved underpackages
folder..node_modules
, we need to use Webpack to bundle them to one single JS file.Usage
b. Build bundle
c. Visit
index.html
with live serverKnown Issues to be Solved
highlight.js
dependency from local to npm module. However I tried different Webpack configs, this package would always be included and caused the bundle oversized (almost 1MB.)webpack-dev-server
plugin maybe, so that the codes could be auto re-build on source file changes.