0

I am writing my own css/js components library and decided to pack it using webpack 3. And some of the components require JQuery. So I want webpack to include JQuery from npm inside the development bundle, to easily test and develop, but I want webpack to exclude it from the production bundle and use global JQuery from the window object instead. Moreover, only a few components require JQuery, so I want to make user of the library to add JQuery if he doesn't want to use this few components. Is it possible to do with webpack and how?

1

1 Answer 1

1

Read about webpack shimming modules.https://webpack.github.io/docs/shimming-modules.html

Here what i am doing. $ will be available in every module without import or require.

plugins: [
    new webpack.ProvidePlugin({
        $: path.resolve(__dirname, "libs/jquery-3.2.1.min.js")
    })
]
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.