Skip to content

Import jQuery to next.config.js #1465

@ghost

Description

Hi,

Is there any way to add a new providerPlugin to the next.config.js file and make a plugin accessible from anywhere in my app.

Example: This is my next.config.js

const webpack = require('webpack');

module.exports = {
  webpack: (config, { dev }) => {

    config.plugins.push(
      new webpack.ProvidePlugin({
        '$': 'jquery',
        jQuery: 'jquery'
      })
    );

    return config
  }
}

And if I try to console.log(jQuery) from my index.js file:

import React from 'react';

module.exports = () =>
  console.log(jQuery);

I still can't access jQuery on the server side, so I get an exception:
ReferenceError: jQuery is not defined

In the end my goal is to import Foundation which has a jQuery dependency and then can't be imported properly in my app.
Thanks for the help!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions