How to use lightgallery with Gatsby/React





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}







0















I'm trying to build an image gallery with Gatsby/React using the jQuery plugin called "lightgallery". I managed to figure out how to get it to work in development. However, when I try to build the site, I run into a problem. Here's my component code



import React, { Component } from 'react'
import Content from '../components/content-container/content'
import $ from 'jquery'
import 'lightgallery'
import 'lg-video'
import 'lg-zoom'

import img_1 from '../images/assets/1.jpg'
import img_2 from '../images/assets/2.jpg'
import img_3 from '../images/assets/3.jpg'

import './gallery.sass'

class Gallery extends Component {
onLightGallery = node => {
this.lightGallery = node
$(node).lightGallery()
}

componentWillUnmount() {
$(this.lightGallery)
.data('lightGallery')
.destroy(true)
}

render() {
return (
<Content>
<Hero heroImage="hero hero-img-gallery">
<h1 className="hero-title">Gallery</h1>
</Hero>
<div className="wrapper">
<p className="title-gallery">Project video</p>
<div className="lightgallery" ref={this.onLightGallery}>
<figure href={img_1}>
<img src={img_1} alt="moxon" />
<figcaption>text</figcaption>
<Play />
</figure>
<figure href={img_2}>
<img src={img_2} alt="thumbnail" />
<figcaption>text</figcaption>
</figure>
<figure href={img_3}>
<img src={img_3} alt="thumbnail" />
<figcaption>text</figcaption>
</figure>
</div>
<p className="title-gallery">images</p>
<div className="lightgallery" ref={this.onLightGallery}>
<figure href={img_1}>
<img src={img_1} alt="thumbnail" />
<figcaption>text</figcaption>
</figure>
<figure href={img_2}>
<img src={img_2} alt="thumbnail" />
<figcaption>text</figcaption>
</figure>
</div>
</div>
</Content>
)
}
}

export default Gallery


Everything works in development, however, when I try to "gatsby build", it throws me the following error:



  1340 |     };
1341 |
> 1342 | $.fn.lightGallery = function(options) {
| ^
1343 | return this.each(function() {
1344 | if (!$.data(this, 'lightGallery')) {
1345 | $.data(this, 'lightGallery', new Plugin(this, options));


WebpackError: TypeError: Cannot set property 'lightGallery' of undefined

- lightgallery.js:1342
[lib]/[lightgallery]/dist/js/lightgallery.js:1342:1

- lightgallery.js:1358
[lib]/[lightgallery]/dist/js/lightgallery.js:1358:2

- lightgallery.js:8 Object.<anonymous>
[lib]/[lightgallery]/dist/js/lightgallery.js:8:1

- lightgallery.js:9 ./node_modules/lightgallery/dist/js/lightgallery.js
[lib]/[lightgallery]/dist/js/lightgallery.js:9:6

- lightgallery.js:18 Object../node_modules/lightgallery/dist/js/lightgallery.js
[lib]/[lightgallery]/dist/js/lightgallery.js:18:2

- bootstrap:19 __webpack_require__
lib/webpack/bootstrap:19:1


- bootstrap:19 __webpack_require__
lib/webpack/bootstrap:19:1

- sync-requires.js:10 Object../.cache/sync-requires.js
lib/.cache/sync-requires.js:10:53

- bootstrap:19 __webpack_require__
lib/webpack/bootstrap:19:1

- static-entry.js:9 Module../.cache/static-entry.js
lib/.cache/static-entry.js:9:22

- bootstrap:19 __webpack_require__
lib/webpack/bootstrap:19:1

- bootstrap:83
lib/webpack/bootstrap:83:1


- universalModuleDefinition:3 webpackUniversalModuleDefinition
lib/webpack/universalModuleDefinition:3:1

- universalModuleDefinition:10 Object.<anonymous>
lib/webpack/universalModuleDefinition:10:2


I have no idea what went wrong and how to fix this issue as I am new to gatsby/react and webpack. Any pointers would be much appreciated!










share|improve this question





























    0















    I'm trying to build an image gallery with Gatsby/React using the jQuery plugin called "lightgallery". I managed to figure out how to get it to work in development. However, when I try to build the site, I run into a problem. Here's my component code



    import React, { Component } from 'react'
    import Content from '../components/content-container/content'
    import $ from 'jquery'
    import 'lightgallery'
    import 'lg-video'
    import 'lg-zoom'

    import img_1 from '../images/assets/1.jpg'
    import img_2 from '../images/assets/2.jpg'
    import img_3 from '../images/assets/3.jpg'

    import './gallery.sass'

    class Gallery extends Component {
    onLightGallery = node => {
    this.lightGallery = node
    $(node).lightGallery()
    }

    componentWillUnmount() {
    $(this.lightGallery)
    .data('lightGallery')
    .destroy(true)
    }

    render() {
    return (
    <Content>
    <Hero heroImage="hero hero-img-gallery">
    <h1 className="hero-title">Gallery</h1>
    </Hero>
    <div className="wrapper">
    <p className="title-gallery">Project video</p>
    <div className="lightgallery" ref={this.onLightGallery}>
    <figure href={img_1}>
    <img src={img_1} alt="moxon" />
    <figcaption>text</figcaption>
    <Play />
    </figure>
    <figure href={img_2}>
    <img src={img_2} alt="thumbnail" />
    <figcaption>text</figcaption>
    </figure>
    <figure href={img_3}>
    <img src={img_3} alt="thumbnail" />
    <figcaption>text</figcaption>
    </figure>
    </div>
    <p className="title-gallery">images</p>
    <div className="lightgallery" ref={this.onLightGallery}>
    <figure href={img_1}>
    <img src={img_1} alt="thumbnail" />
    <figcaption>text</figcaption>
    </figure>
    <figure href={img_2}>
    <img src={img_2} alt="thumbnail" />
    <figcaption>text</figcaption>
    </figure>
    </div>
    </div>
    </Content>
    )
    }
    }

    export default Gallery


    Everything works in development, however, when I try to "gatsby build", it throws me the following error:



      1340 |     };
    1341 |
    > 1342 | $.fn.lightGallery = function(options) {
    | ^
    1343 | return this.each(function() {
    1344 | if (!$.data(this, 'lightGallery')) {
    1345 | $.data(this, 'lightGallery', new Plugin(this, options));


    WebpackError: TypeError: Cannot set property 'lightGallery' of undefined

    - lightgallery.js:1342
    [lib]/[lightgallery]/dist/js/lightgallery.js:1342:1

    - lightgallery.js:1358
    [lib]/[lightgallery]/dist/js/lightgallery.js:1358:2

    - lightgallery.js:8 Object.<anonymous>
    [lib]/[lightgallery]/dist/js/lightgallery.js:8:1

    - lightgallery.js:9 ./node_modules/lightgallery/dist/js/lightgallery.js
    [lib]/[lightgallery]/dist/js/lightgallery.js:9:6

    - lightgallery.js:18 Object../node_modules/lightgallery/dist/js/lightgallery.js
    [lib]/[lightgallery]/dist/js/lightgallery.js:18:2

    - bootstrap:19 __webpack_require__
    lib/webpack/bootstrap:19:1


    - bootstrap:19 __webpack_require__
    lib/webpack/bootstrap:19:1

    - sync-requires.js:10 Object../.cache/sync-requires.js
    lib/.cache/sync-requires.js:10:53

    - bootstrap:19 __webpack_require__
    lib/webpack/bootstrap:19:1

    - static-entry.js:9 Module../.cache/static-entry.js
    lib/.cache/static-entry.js:9:22

    - bootstrap:19 __webpack_require__
    lib/webpack/bootstrap:19:1

    - bootstrap:83
    lib/webpack/bootstrap:83:1


    - universalModuleDefinition:3 webpackUniversalModuleDefinition
    lib/webpack/universalModuleDefinition:3:1

    - universalModuleDefinition:10 Object.<anonymous>
    lib/webpack/universalModuleDefinition:10:2


    I have no idea what went wrong and how to fix this issue as I am new to gatsby/react and webpack. Any pointers would be much appreciated!










    share|improve this question

























      0












      0








      0








      I'm trying to build an image gallery with Gatsby/React using the jQuery plugin called "lightgallery". I managed to figure out how to get it to work in development. However, when I try to build the site, I run into a problem. Here's my component code



      import React, { Component } from 'react'
      import Content from '../components/content-container/content'
      import $ from 'jquery'
      import 'lightgallery'
      import 'lg-video'
      import 'lg-zoom'

      import img_1 from '../images/assets/1.jpg'
      import img_2 from '../images/assets/2.jpg'
      import img_3 from '../images/assets/3.jpg'

      import './gallery.sass'

      class Gallery extends Component {
      onLightGallery = node => {
      this.lightGallery = node
      $(node).lightGallery()
      }

      componentWillUnmount() {
      $(this.lightGallery)
      .data('lightGallery')
      .destroy(true)
      }

      render() {
      return (
      <Content>
      <Hero heroImage="hero hero-img-gallery">
      <h1 className="hero-title">Gallery</h1>
      </Hero>
      <div className="wrapper">
      <p className="title-gallery">Project video</p>
      <div className="lightgallery" ref={this.onLightGallery}>
      <figure href={img_1}>
      <img src={img_1} alt="moxon" />
      <figcaption>text</figcaption>
      <Play />
      </figure>
      <figure href={img_2}>
      <img src={img_2} alt="thumbnail" />
      <figcaption>text</figcaption>
      </figure>
      <figure href={img_3}>
      <img src={img_3} alt="thumbnail" />
      <figcaption>text</figcaption>
      </figure>
      </div>
      <p className="title-gallery">images</p>
      <div className="lightgallery" ref={this.onLightGallery}>
      <figure href={img_1}>
      <img src={img_1} alt="thumbnail" />
      <figcaption>text</figcaption>
      </figure>
      <figure href={img_2}>
      <img src={img_2} alt="thumbnail" />
      <figcaption>text</figcaption>
      </figure>
      </div>
      </div>
      </Content>
      )
      }
      }

      export default Gallery


      Everything works in development, however, when I try to "gatsby build", it throws me the following error:



        1340 |     };
      1341 |
      > 1342 | $.fn.lightGallery = function(options) {
      | ^
      1343 | return this.each(function() {
      1344 | if (!$.data(this, 'lightGallery')) {
      1345 | $.data(this, 'lightGallery', new Plugin(this, options));


      WebpackError: TypeError: Cannot set property 'lightGallery' of undefined

      - lightgallery.js:1342
      [lib]/[lightgallery]/dist/js/lightgallery.js:1342:1

      - lightgallery.js:1358
      [lib]/[lightgallery]/dist/js/lightgallery.js:1358:2

      - lightgallery.js:8 Object.<anonymous>
      [lib]/[lightgallery]/dist/js/lightgallery.js:8:1

      - lightgallery.js:9 ./node_modules/lightgallery/dist/js/lightgallery.js
      [lib]/[lightgallery]/dist/js/lightgallery.js:9:6

      - lightgallery.js:18 Object../node_modules/lightgallery/dist/js/lightgallery.js
      [lib]/[lightgallery]/dist/js/lightgallery.js:18:2

      - bootstrap:19 __webpack_require__
      lib/webpack/bootstrap:19:1


      - bootstrap:19 __webpack_require__
      lib/webpack/bootstrap:19:1

      - sync-requires.js:10 Object../.cache/sync-requires.js
      lib/.cache/sync-requires.js:10:53

      - bootstrap:19 __webpack_require__
      lib/webpack/bootstrap:19:1

      - static-entry.js:9 Module../.cache/static-entry.js
      lib/.cache/static-entry.js:9:22

      - bootstrap:19 __webpack_require__
      lib/webpack/bootstrap:19:1

      - bootstrap:83
      lib/webpack/bootstrap:83:1


      - universalModuleDefinition:3 webpackUniversalModuleDefinition
      lib/webpack/universalModuleDefinition:3:1

      - universalModuleDefinition:10 Object.<anonymous>
      lib/webpack/universalModuleDefinition:10:2


      I have no idea what went wrong and how to fix this issue as I am new to gatsby/react and webpack. Any pointers would be much appreciated!










      share|improve this question














      I'm trying to build an image gallery with Gatsby/React using the jQuery plugin called "lightgallery". I managed to figure out how to get it to work in development. However, when I try to build the site, I run into a problem. Here's my component code



      import React, { Component } from 'react'
      import Content from '../components/content-container/content'
      import $ from 'jquery'
      import 'lightgallery'
      import 'lg-video'
      import 'lg-zoom'

      import img_1 from '../images/assets/1.jpg'
      import img_2 from '../images/assets/2.jpg'
      import img_3 from '../images/assets/3.jpg'

      import './gallery.sass'

      class Gallery extends Component {
      onLightGallery = node => {
      this.lightGallery = node
      $(node).lightGallery()
      }

      componentWillUnmount() {
      $(this.lightGallery)
      .data('lightGallery')
      .destroy(true)
      }

      render() {
      return (
      <Content>
      <Hero heroImage="hero hero-img-gallery">
      <h1 className="hero-title">Gallery</h1>
      </Hero>
      <div className="wrapper">
      <p className="title-gallery">Project video</p>
      <div className="lightgallery" ref={this.onLightGallery}>
      <figure href={img_1}>
      <img src={img_1} alt="moxon" />
      <figcaption>text</figcaption>
      <Play />
      </figure>
      <figure href={img_2}>
      <img src={img_2} alt="thumbnail" />
      <figcaption>text</figcaption>
      </figure>
      <figure href={img_3}>
      <img src={img_3} alt="thumbnail" />
      <figcaption>text</figcaption>
      </figure>
      </div>
      <p className="title-gallery">images</p>
      <div className="lightgallery" ref={this.onLightGallery}>
      <figure href={img_1}>
      <img src={img_1} alt="thumbnail" />
      <figcaption>text</figcaption>
      </figure>
      <figure href={img_2}>
      <img src={img_2} alt="thumbnail" />
      <figcaption>text</figcaption>
      </figure>
      </div>
      </div>
      </Content>
      )
      }
      }

      export default Gallery


      Everything works in development, however, when I try to "gatsby build", it throws me the following error:



        1340 |     };
      1341 |
      > 1342 | $.fn.lightGallery = function(options) {
      | ^
      1343 | return this.each(function() {
      1344 | if (!$.data(this, 'lightGallery')) {
      1345 | $.data(this, 'lightGallery', new Plugin(this, options));


      WebpackError: TypeError: Cannot set property 'lightGallery' of undefined

      - lightgallery.js:1342
      [lib]/[lightgallery]/dist/js/lightgallery.js:1342:1

      - lightgallery.js:1358
      [lib]/[lightgallery]/dist/js/lightgallery.js:1358:2

      - lightgallery.js:8 Object.<anonymous>
      [lib]/[lightgallery]/dist/js/lightgallery.js:8:1

      - lightgallery.js:9 ./node_modules/lightgallery/dist/js/lightgallery.js
      [lib]/[lightgallery]/dist/js/lightgallery.js:9:6

      - lightgallery.js:18 Object../node_modules/lightgallery/dist/js/lightgallery.js
      [lib]/[lightgallery]/dist/js/lightgallery.js:18:2

      - bootstrap:19 __webpack_require__
      lib/webpack/bootstrap:19:1


      - bootstrap:19 __webpack_require__
      lib/webpack/bootstrap:19:1

      - sync-requires.js:10 Object../.cache/sync-requires.js
      lib/.cache/sync-requires.js:10:53

      - bootstrap:19 __webpack_require__
      lib/webpack/bootstrap:19:1

      - static-entry.js:9 Module../.cache/static-entry.js
      lib/.cache/static-entry.js:9:22

      - bootstrap:19 __webpack_require__
      lib/webpack/bootstrap:19:1

      - bootstrap:83
      lib/webpack/bootstrap:83:1


      - universalModuleDefinition:3 webpackUniversalModuleDefinition
      lib/webpack/universalModuleDefinition:3:1

      - universalModuleDefinition:10 Object.<anonymous>
      lib/webpack/universalModuleDefinition:10:2


      I have no idea what went wrong and how to fix this issue as I am new to gatsby/react and webpack. Any pointers would be much appreciated!







      jquery reactjs webpack gatsby lightgallery






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 17 '18 at 6:48









      York WangYork Wang

      5952714




      5952714
























          1 Answer
          1






          active

          oldest

          votes


















          1














          You're running into this issue because the lightgallery code is being run on the server where window and other parts of the DOM are not available. You can learn more about how to debug and workaround this in the official Gatsby documentation here.



          That resource recommends the following to exclude the third-party library from being evaluated server-side:



          exports.onCreateWebpackConfig = ({ stage, loaders, actions }) => {
          if (stage === "build-html") {
          actions.setWebpackConfig({
          module: {
          rules: [
          {
          test: /bad-module/,
          use: loaders.null(),
          },
          ],
          },
          })
          }
          }





          share|improve this answer
























          • @codreyward thank you for the reply. I think I understand the issue now, however, I do not know exactly how to use the example code above to exclude the lightgallery library. could you demonstrate how to do it? I'm pretty new to Gatsby and Webpack, a more detailed code sample would be super helpful!

            – York Wang
            Nov 19 '18 at 20:49






          • 1





            @YorkWang If you review the linked doc it may help. I'll also note that this would go in your gatsby-node.js file (you may not have one yet), and you would want to replace the /bad-module/ expression with one that will match the library you want to exclude (e.g. /lightgallery/).

            – coreyward
            Nov 19 '18 at 21:28











          • thank you so much!! it worked! I have one last question if I may. I have two plugins that i need to exclude, one is lightgallery, and the other one is lg-video, which is a separate plugin for lightgallery. I tried to add /lg-video/ right after /lightgallery/, and that seems to break the build process? thanks so much again for your help!

            – York Wang
            Nov 19 '18 at 21:46






          • 1





            You can combine them in the regular expression: /(lightgallery|lg-video)/.

            – coreyward
            Nov 19 '18 at 22:11











          • Thank you so so much!

            – York Wang
            Nov 19 '18 at 22:40












          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53348934%2fhow-to-use-lightgallery-with-gatsby-react%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          1














          You're running into this issue because the lightgallery code is being run on the server where window and other parts of the DOM are not available. You can learn more about how to debug and workaround this in the official Gatsby documentation here.



          That resource recommends the following to exclude the third-party library from being evaluated server-side:



          exports.onCreateWebpackConfig = ({ stage, loaders, actions }) => {
          if (stage === "build-html") {
          actions.setWebpackConfig({
          module: {
          rules: [
          {
          test: /bad-module/,
          use: loaders.null(),
          },
          ],
          },
          })
          }
          }





          share|improve this answer
























          • @codreyward thank you for the reply. I think I understand the issue now, however, I do not know exactly how to use the example code above to exclude the lightgallery library. could you demonstrate how to do it? I'm pretty new to Gatsby and Webpack, a more detailed code sample would be super helpful!

            – York Wang
            Nov 19 '18 at 20:49






          • 1





            @YorkWang If you review the linked doc it may help. I'll also note that this would go in your gatsby-node.js file (you may not have one yet), and you would want to replace the /bad-module/ expression with one that will match the library you want to exclude (e.g. /lightgallery/).

            – coreyward
            Nov 19 '18 at 21:28











          • thank you so much!! it worked! I have one last question if I may. I have two plugins that i need to exclude, one is lightgallery, and the other one is lg-video, which is a separate plugin for lightgallery. I tried to add /lg-video/ right after /lightgallery/, and that seems to break the build process? thanks so much again for your help!

            – York Wang
            Nov 19 '18 at 21:46






          • 1





            You can combine them in the regular expression: /(lightgallery|lg-video)/.

            – coreyward
            Nov 19 '18 at 22:11











          • Thank you so so much!

            – York Wang
            Nov 19 '18 at 22:40
















          1














          You're running into this issue because the lightgallery code is being run on the server where window and other parts of the DOM are not available. You can learn more about how to debug and workaround this in the official Gatsby documentation here.



          That resource recommends the following to exclude the third-party library from being evaluated server-side:



          exports.onCreateWebpackConfig = ({ stage, loaders, actions }) => {
          if (stage === "build-html") {
          actions.setWebpackConfig({
          module: {
          rules: [
          {
          test: /bad-module/,
          use: loaders.null(),
          },
          ],
          },
          })
          }
          }





          share|improve this answer
























          • @codreyward thank you for the reply. I think I understand the issue now, however, I do not know exactly how to use the example code above to exclude the lightgallery library. could you demonstrate how to do it? I'm pretty new to Gatsby and Webpack, a more detailed code sample would be super helpful!

            – York Wang
            Nov 19 '18 at 20:49






          • 1





            @YorkWang If you review the linked doc it may help. I'll also note that this would go in your gatsby-node.js file (you may not have one yet), and you would want to replace the /bad-module/ expression with one that will match the library you want to exclude (e.g. /lightgallery/).

            – coreyward
            Nov 19 '18 at 21:28











          • thank you so much!! it worked! I have one last question if I may. I have two plugins that i need to exclude, one is lightgallery, and the other one is lg-video, which is a separate plugin for lightgallery. I tried to add /lg-video/ right after /lightgallery/, and that seems to break the build process? thanks so much again for your help!

            – York Wang
            Nov 19 '18 at 21:46






          • 1





            You can combine them in the regular expression: /(lightgallery|lg-video)/.

            – coreyward
            Nov 19 '18 at 22:11











          • Thank you so so much!

            – York Wang
            Nov 19 '18 at 22:40














          1












          1








          1







          You're running into this issue because the lightgallery code is being run on the server where window and other parts of the DOM are not available. You can learn more about how to debug and workaround this in the official Gatsby documentation here.



          That resource recommends the following to exclude the third-party library from being evaluated server-side:



          exports.onCreateWebpackConfig = ({ stage, loaders, actions }) => {
          if (stage === "build-html") {
          actions.setWebpackConfig({
          module: {
          rules: [
          {
          test: /bad-module/,
          use: loaders.null(),
          },
          ],
          },
          })
          }
          }





          share|improve this answer













          You're running into this issue because the lightgallery code is being run on the server where window and other parts of the DOM are not available. You can learn more about how to debug and workaround this in the official Gatsby documentation here.



          That resource recommends the following to exclude the third-party library from being evaluated server-side:



          exports.onCreateWebpackConfig = ({ stage, loaders, actions }) => {
          if (stage === "build-html") {
          actions.setWebpackConfig({
          module: {
          rules: [
          {
          test: /bad-module/,
          use: loaders.null(),
          },
          ],
          },
          })
          }
          }






          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 19 '18 at 18:09









          coreywardcoreyward

          51.3k1599127




          51.3k1599127













          • @codreyward thank you for the reply. I think I understand the issue now, however, I do not know exactly how to use the example code above to exclude the lightgallery library. could you demonstrate how to do it? I'm pretty new to Gatsby and Webpack, a more detailed code sample would be super helpful!

            – York Wang
            Nov 19 '18 at 20:49






          • 1





            @YorkWang If you review the linked doc it may help. I'll also note that this would go in your gatsby-node.js file (you may not have one yet), and you would want to replace the /bad-module/ expression with one that will match the library you want to exclude (e.g. /lightgallery/).

            – coreyward
            Nov 19 '18 at 21:28











          • thank you so much!! it worked! I have one last question if I may. I have two plugins that i need to exclude, one is lightgallery, and the other one is lg-video, which is a separate plugin for lightgallery. I tried to add /lg-video/ right after /lightgallery/, and that seems to break the build process? thanks so much again for your help!

            – York Wang
            Nov 19 '18 at 21:46






          • 1





            You can combine them in the regular expression: /(lightgallery|lg-video)/.

            – coreyward
            Nov 19 '18 at 22:11











          • Thank you so so much!

            – York Wang
            Nov 19 '18 at 22:40



















          • @codreyward thank you for the reply. I think I understand the issue now, however, I do not know exactly how to use the example code above to exclude the lightgallery library. could you demonstrate how to do it? I'm pretty new to Gatsby and Webpack, a more detailed code sample would be super helpful!

            – York Wang
            Nov 19 '18 at 20:49






          • 1





            @YorkWang If you review the linked doc it may help. I'll also note that this would go in your gatsby-node.js file (you may not have one yet), and you would want to replace the /bad-module/ expression with one that will match the library you want to exclude (e.g. /lightgallery/).

            – coreyward
            Nov 19 '18 at 21:28











          • thank you so much!! it worked! I have one last question if I may. I have two plugins that i need to exclude, one is lightgallery, and the other one is lg-video, which is a separate plugin for lightgallery. I tried to add /lg-video/ right after /lightgallery/, and that seems to break the build process? thanks so much again for your help!

            – York Wang
            Nov 19 '18 at 21:46






          • 1





            You can combine them in the regular expression: /(lightgallery|lg-video)/.

            – coreyward
            Nov 19 '18 at 22:11











          • Thank you so so much!

            – York Wang
            Nov 19 '18 at 22:40

















          @codreyward thank you for the reply. I think I understand the issue now, however, I do not know exactly how to use the example code above to exclude the lightgallery library. could you demonstrate how to do it? I'm pretty new to Gatsby and Webpack, a more detailed code sample would be super helpful!

          – York Wang
          Nov 19 '18 at 20:49





          @codreyward thank you for the reply. I think I understand the issue now, however, I do not know exactly how to use the example code above to exclude the lightgallery library. could you demonstrate how to do it? I'm pretty new to Gatsby and Webpack, a more detailed code sample would be super helpful!

          – York Wang
          Nov 19 '18 at 20:49




          1




          1





          @YorkWang If you review the linked doc it may help. I'll also note that this would go in your gatsby-node.js file (you may not have one yet), and you would want to replace the /bad-module/ expression with one that will match the library you want to exclude (e.g. /lightgallery/).

          – coreyward
          Nov 19 '18 at 21:28





          @YorkWang If you review the linked doc it may help. I'll also note that this would go in your gatsby-node.js file (you may not have one yet), and you would want to replace the /bad-module/ expression with one that will match the library you want to exclude (e.g. /lightgallery/).

          – coreyward
          Nov 19 '18 at 21:28













          thank you so much!! it worked! I have one last question if I may. I have two plugins that i need to exclude, one is lightgallery, and the other one is lg-video, which is a separate plugin for lightgallery. I tried to add /lg-video/ right after /lightgallery/, and that seems to break the build process? thanks so much again for your help!

          – York Wang
          Nov 19 '18 at 21:46





          thank you so much!! it worked! I have one last question if I may. I have two plugins that i need to exclude, one is lightgallery, and the other one is lg-video, which is a separate plugin for lightgallery. I tried to add /lg-video/ right after /lightgallery/, and that seems to break the build process? thanks so much again for your help!

          – York Wang
          Nov 19 '18 at 21:46




          1




          1





          You can combine them in the regular expression: /(lightgallery|lg-video)/.

          – coreyward
          Nov 19 '18 at 22:11





          You can combine them in the regular expression: /(lightgallery|lg-video)/.

          – coreyward
          Nov 19 '18 at 22:11













          Thank you so so much!

          – York Wang
          Nov 19 '18 at 22:40





          Thank you so so much!

          – York Wang
          Nov 19 '18 at 22:40




















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53348934%2fhow-to-use-lightgallery-with-gatsby-react%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Bressuire

          Vorschmack

          Quarantine