Skip to content

Commit

Permalink
fix(javascriptservices): update configuration to set public path for …
Browse files Browse the repository at this point in the history
…static resources

The webpack build moves files into the /dist/ folder and resources are loaded from the root '/' publicPath
This adds a change to the webpack.netcore.config.js file that customizes webpack to work with javascript services by adding the publicPath to the url and file loaders.

Relates to a discussion on a previous PR #741
  • Loading branch information
grufffta committed Nov 9, 2017
1 parent e5b479c commit 21e8a27
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions lib/resources/content/javascriptservices/webpack.netcore.config.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,24 @@
const webpackConfig = require('./webpack.config');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const CleanWebpackPlugin = require('clean-webpack-plugin');
const project = require('./aurelia_project/aurelia.json');
var originalConfig = webpackConfig({});

module.exports = () => {
let config = originalConfig;
// output files without hashes
config.output.filename = '[name].bundle.js';
config.plugins.splice(config.plugins.indexOf(HtmlWebpackPlugin));
// fix output path for .net core development
config.module.rules = config.module.rules.map(x => {
if (x.loader && (x.loader === 'url-loader' || x.loader === 'file-loader')) {
if (!x.options) {
x.options = {};
}
x.options.publicPath = project.platform.output.replace('wwwroot', '') + '/';
}
return x;
});
config.plugins = [
// first clean the output directory
new CleanWebpackPlugin([config.output.path]),
Expand Down

0 comments on commit 21e8a27

Please sign in to comment.