Successfully added
React
by Patrik
Configure Webpack for Development
To configure Webpack to bundle your application into a single bundle file, create a webpack.config.js
file under the root of the project and put the following module.exports
object in it:
webpack.config.js
const path = require('path'); | |
module.exports = { | |
mode: 'development', | |
entry: './src/index.jsx', | |
output: { | |
path: path.resolve(__dirname, '../wwwroot/js'), | |
filename: 'snippset.js' | |
}, | |
module: { | |
rules: [ | |
{ | |
test: /\.jsx$/, | |
exclude: /(node_modules)/, | |
use: [{ | |
loader: 'babel-loader', | |
} | |
] | |
} | |
] | |
}, | |
resolve: { | |
extensions: ['.js', '.jsx'] | |
} | |
}; |
Webpack has certain defaults on which JavaScript file to start with. It looks for asrc/index.js
file. It’ll also output the bundle todist/main.js
by default. If you need to change the locations of yoursrc
anddist
files, you’ll need a few more configuration entries inwebpack.config.js
.
Referenced in:
Comments