Skip to content

Commit

Permalink
Reduce browser build size 1450kB -> 820kB
Browse files Browse the repository at this point in the history
  • Loading branch information
TrySound committed Feb 19, 2021
1 parent a7cc20b commit 82778c8
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
"test": "nyc --reporter=html --reporter=text mocha \"test/*/_index.js\"",
"lint": "eslint .",
"test-browser": "rollup -c && node ./test/browser.js",
"prepublishOnly": "rollup -c"
"prepublishOnly": "rm -rf dist && rollup -c"
},
"eslintConfig": {
"ignorePatterns": [
Expand Down
6 changes: 5 additions & 1 deletion rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,14 @@ export default {
},
plugins: [
{
resolveId(importee) {
resolveId(importee, importer) {
if (['os', 'stream', 'string_decoder'].includes(importee)) {
return importee;
}
// see https://github.com/csstree/csstree/pull/152
if (importee === 'css-tree') {
return this.resolve('css-tree/dist/csstree.min.js', importer);
}
},
load(id) {
if (id === 'os') {
Expand Down
1 change: 1 addition & 0 deletions test/browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ const runTest = async () => {
server.listen(5000, async () => {
try {
await runTest();
console.info('Tested successfully');
server.close()
} catch (error) {
server.close();
Expand Down

0 comments on commit 82778c8

Please sign in to comment.