Skip to content

Commit

Permalink
refactor: get hmr working with new context
Browse files Browse the repository at this point in the history
String replace based on filename coming in
  • Loading branch information
ScriptedAlchemy committed Jan 24, 2019
1 parent 50b3fd8 commit c2207af
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/hmr/hotModuleReplacement.js
Expand Up @@ -38,11 +38,17 @@ function getCurrentScriptUrl(moduleId) {
}

return function(fileMap) {
const splitResult = /([^\\/]+)\.js$/.exec(src);
if (!src) {
return null;
}
const splitResult = src.split(/([^\\/]+)\.js$/);
const filename = splitResult && splitResult[1];
if (!filename) {
return [src.replace('.js', '.css')];
}
if (!fileMap) {
return [src.replace('.js', '.css')];
}
return fileMap.split(',').map(mapRule => {
const reg = new RegExp(`${filename}\\.js$`, 'g');
return normalizeUrl(
Expand Down
1 change: 1 addition & 0 deletions src/index.js
Expand Up @@ -110,6 +110,7 @@ class CssModuleFactory {

class MiniCssExtractPlugin {
constructor(options) {
console.log('options', options);
this.options = Object.assign(
{
filename: '[name].css',
Expand Down

0 comments on commit c2207af

Please sign in to comment.