Last active
September 19, 2020 14:06
-
-
Save hangst/1ed2a4595d51ac5adfc0d4bff718480d to your computer and use it in GitHub Desktop.
Bundles and minifies Material Web Components
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
folder=mwc_$(date +%s%N) | |
mkdir $folder | |
cd $folder | |
sudo apt-get -qq --assume-yes install minify npm | |
eval npm install \ | |
@material/mwc-button \ | |
@material/mwc-checkbox \ | |
@material/mwc-circular-progress \ | |
@material/mwc-circular-progress-four-color \ | |
@material/mwc-dialog \ | |
@material/mwc-drawer \ | |
@material/mwc-fab \ | |
@material/mwc-formfield \ | |
@material/mwc-icon-button-toggle \ | |
@material/mwc-icon-button \ | |
@material/mwc-icon \ | |
@material/mwc-linear-progress \ | |
@material/mwc-list \ | |
@material/mwc-menu \ | |
@material/mwc-radio \ | |
@material/mwc-select \ | |
@material/mwc-slider \ | |
@material/mwc-snackbar \ | |
@material/mwc-switch \ | |
@material/mwc-tab-bar \ | |
@material/mwc-tab \ | |
@material/mwc-textarea \ | |
@material/mwc-textfield \ | |
@material/mwc-top-app-bar-fixed \ | |
@material/mwc-top-app-bar \ rollup \ | |
@rollup/plugin-node-resolve \ | |
@webcomponents/webcomponentsjs | |
# Compile a list of *.js | |
echo import \"$(find ./node_modules -name webcomponents-loader.js)\" > all.js | |
for i in $(find -iname '*.js' | grep ./node_modules/@material/mwc-); do | |
echo import \"$i\" >> all.js | |
done | |
# Bundle into mwc.js | |
echo "\ | |
import resolve from '@rollup/plugin-node-resolve' | |
export default { | |
input: 'all.js', | |
output: { file: 'mwc.js' }, | |
plugins: [resolve()] | |
}" > rollup.config.js | |
node_modules/.bin/rollup -c | |
# Minify bundled modules | |
minify mwc.js > ../mwc.min.js | |
cd .. | |
# Cleanup | |
rm -rf $folder |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment