3

The scenario is that I'm developing a component for use by a website and want to combine the files that I've created into one index.js for ease of use.

File index.jsx includes the line var header = require('./header.jsx'); and header.jsx includes the line var React = require('react'); where React has been added as an npm module.

If I use webpack --module-bind jsx --entry .\src\index.jsx --output-file .\dist\index.js on the command line this produces a large file with React source included.

Is there a way that I can have just my index.jsx and header.jsx transformed and concatenated?

1 Answer 1

4

You can mark React as an external to achieve that. Ie.

externals: {
    react: 'react',
}
Sign up to request clarification or add additional context in comments.

1 Comment

This is correct for a single dependency. For multiple dependencies I used var fs = require('fs'), node_modules = fs.readdirSync('node_modules'); module.exports = { externals: node_modules };

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.