Here is my setup in webpack.config.js:
entry: {
a:'./src/a.js',
b:'./src/b.js'
},
output: {
path: path.join(__dirname, 'dist'),
filename: '[name].bundle.js'
}
The content of a.js includes:
const MSG = "Can you see me?";
And the content of b.js includes:
console.log(MSG);
In my index.html file, I have included both bundled scripts:
<script type="text/javascript" src="./dist/a.bundle.js"></script>
<script type="text/javascript" src="./dist/b.bundle.js"></script>
When I run npm build or use babel-loader, everything works fine. However, I'm getting an error saying "Uncaught ReferenceError: MSG is not defined" even though it is defined in a.js. Am I missing something here? Do I need additional configurations to access values between different entry points?