feed.html:
<script src="feed-bundle.js"> </script>
profile.html:
<script src="profile-bundle.js"> </script>
feed.html:
<script src="feed-bundle.js"> </script>
<script src="common.js"> </script>
profile.html:
<script src="profile-bundle.js"> </script>
<script src="common.js"> </script>
require('./style.scss');
var imgElement = document.createElement('img');
imgElement.src = require('./image.png');
document.body.appendChild(imgElement);
module.exports = {
entry: './main.js',
output: {
filename: 'bundle.js'
},
module: {
loaders: [
{test: /\.scss$/, loader: "style!css!sass"},
{test: /\.png$/, loader: "url-loader?limit=10000"}
]
}
};
Loading
// Front-end router
window.onpopstate = function() {
showLoadingIndicator();
if (window.location.pathname === '/profile') {
require.ensure([], function() {
hideLoadingIndicator();
require('./pages/profile').show();
});
} else if (window.lcation.pathname === '/feed') {
require.ensure([], function() {
hideLoadingIndicator();
require('./pages/feed').show();
});
}
}