Open Shard opened 8 years ago
When it comes to loading the build in SF from both webpack-dev-server (If the user has it running) and having it fallback to compiled assets, I have made a basic JS solution:
jQuery(document).ready(function(){ var devUrl = 'http://localhost:8080'; jQuery.get(devUrl + '/js/app.js', function(){ console.info('Webpack Dev Mode Enabled!'); $('<script />').attr('src', devUrl + '/js/app.js').appendTo('body') $('<link />').attr('rel', 'shortcut icon').attr('href', 'https://topheman.github.io/webpack-babel-starter/assets/974262647c82057b6078c432841a53ea.png').prependTo('head') }).fail(function(){ console.info('Webpack Dev Mode Disabled!'); $('<link />') .attr('href', '/ResourcePackages/assets/css/styles.css') .attr('rel', 'stylesheet') .appendTo('body'); $('<script />').attr('src', '/ResourcePackages/assets/js/app.js').appendTo('body'); }) })
The major downside is that it requires either configuring SF or your browser to allow origin "localhost:8080" otherwise you will have a CORS issue.
We could fix this issue by moving the logic into the razor template.
When it comes to loading the build in SF from both webpack-dev-server (If the user has it running) and having it fallback to compiled assets, I have made a basic JS solution:
The major downside is that it requires either configuring SF or your browser to allow origin "localhost:8080" otherwise you will have a CORS issue.
We could fix this issue by moving the logic into the razor template.