I have created a single page web app using react js. I have used webpack
to create bundle of all components. But now I want to create many other pages. Most of pages are API call related. i.e. in the index.html
, I have displayed content from API
. I want to insert content in another page parsing data from API. Webpack compresses everything of react in a file which is bundle.js
. However, the configuration of webpack
is as follow:
const webpack = require('webpack');
var config = {
entry: './main.js',
output: {
path:'./',
filename: 'dist/bundle.js',
},
devServer: {
inline: true,
port: 3000
},
module: {
loaders: [
{
test: /\.jsx?$/,
exclude: /node_modules/,
loader: 'babel',
query: {
presets: ['es2015', 'react']
}
}
]
},
plugins: [
new webpack.DefinePlugin({
'process.env': {
'NODE_ENV': JSON.stringify('production')
}
}),
new webpack.optimize.UglifyJsPlugin({
compress: {
warnings: false
}
})
]
}
module.exports = config;
Now, I am confused what kind of configuration of webpack
will be for other page or what is the correct way to build multi-pages app using react.js