Lanz
Lanz

Reputation: 59

Can't not use jimp with webpack

I'm using jimp with webpack,but the page alway show this:

Uncaught Error: define cannot be used indirect

Also I have try to add module.noParses config in my webpack.config.js like below:

noParse: [/jimp/]

but it will console other error:

Uncaught ReferenceError: require is not defined

Just so confused,no really where the problem is,maybe the jimp is not incompatible with webpack?

Thanks in advanced.

Upvotes: 0

Views: 1091

Answers (1)

Steve Bazyl
Steve Bazyl

Reputation: 11672

Ran into this myself, looks like using the imports loader helps:

import 'imports?require=>false!path/to/jimp.js'

You can also do it via webpack.config.js in module.loaders:

{
    test: /jimp/,
    loader: 'imports?require=>false',
}

If you have other loaders (e.g. babel) you might also need to exclude jimp from that config as well.

Upvotes: 1

Related Questions