travis-r6s / gridsome-plugin-brotli Goto Github PK
View Code? Open in Web Editor NEWGridsome plugin for preparing brotli-compressed versions of assets
License: MIT License
Gridsome plugin for preparing brotli-compressed versions of assets
License: MIT License
Awesome plugin! Thanks for taking the time to put it together.
I was working on a site and had an issue come up while building. Perhaps others have ran into it as well.
It appears that when the index.vue
page is missing a data property, or the data property returned by a function is empty, the compression fails for JSON files (dist/assets/data
).
Here is the error output:
TypeError [ERR_INVALID_ARG_TYPE]: The "data" argument must be of type string or an instance of Buffer, TypedArray, or DataView. Received null
at writeFile (fs.js:1356:5)
at internal/util.js:297:30
at new Promise (<anonymous>)
at writeFile (internal/util.js:296:12)
at compressFile (/path/to/my/site/node_modules/gridsome-plugin-brotli/worker.js:24:9)
Sample index.vue
that causes the error:
<template>
<h1>Home</h1>
</template>
<script>
export default {
metaInfo: {
title: 'Home'
},
data(){
return {}
}
}
</script>
Outputted JSON file that fails compression (dist/assets/data/index.json
):
{"hash":"a38dd2e542c0e62025c3d51f01861b88ab2a01d2","data":null,"context":{}}
Strangely, even with an empty, defined data property, the outputted JSON file is identical.
// template from previous example still applies
<script>
export default {
metaInfo: {
title: 'Home'
},
data: {}
}
</script>
Outputted JSON that successfully compresses (dist/assets/data/index.json
):
{"hash":"4a3972e9372535a0402b06f00b5337886e621d75","data":null,"context":{}}
Any ideas on the cause of this? It's easy to add a data property to the vue file and move on, but this may catch others off-guard, like it did to me.
Hey there,
the README's last line mentions gatsby build && gatsby serve
, eventhough this plugin is for Gridsome.
Hi I just noticed that if there is some other plugin that creates files in the output dir via api.afterBuild it happens that the brotoli plugin fails to compress all the files.
Is there some way to wait for all other plugins to finish?
For testing I added in the plugin on line 10 in the function api.afterBuild(async ({ config }) => {
await new Promise(resolve => setTimeout(resolve, 1));
and this was on my system enough to wait for the finish of the @microflash/gridsome-plugin-feed plugin that generates rss and atom feeds that then are compressed by the brotoli plugin.
Regards
Alex
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.