Giter Club home page Giter Club logo

gridsome-plugin-brotli's People

Contributors

dependabot[bot] avatar travis-r6s avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar

gridsome-plugin-brotli's Issues

JSON compression fails for empty/missing index.vue data property

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.

Gatsby Leftover

Hey there,
the README's last line mentions gatsby build && gatsby serve, eventhough this plugin is for Gridsome.

wait for other afterBuild finished

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.