webpack-runtime-public-path-plugin
Advanced tools
Comparing version 1.1.1 to 1.1.2
39
index.js
@@ -6,5 +6,16 @@ /** | ||
function RuntimePublicPath(options) { | ||
this.options = options | ||
this.options = options; | ||
this._name = 'WebpackRuntimePublicPathPlugin'; | ||
} | ||
RuntimePublicPath.prototype.apply = function(compiler) { | ||
function buf(path, source) { | ||
var buf = []; | ||
buf.push(source); | ||
buf.push(''); | ||
buf.push('// Dynamic assets path override (webpack-runtime-public-path-plugin)'); | ||
buf.push('__webpack_require__.p = (' + path + ') || __webpack_require__.p;'); | ||
return buf.join('\n'); | ||
} | ||
RuntimePublicPath.prototype.apply = function (compiler) { | ||
var runtimePublicPathStr = this.options && this.options.runtimePublicPath; | ||
@@ -15,14 +26,18 @@ if (!runtimePublicPathStr) { | ||
} | ||
compiler.plugin('this-compilation', function(compilation) { | ||
compilation.mainTemplate.plugin('require-extensions', function(source, chunk, hash) { | ||
var buf = []; | ||
buf.push(source); | ||
buf.push(''); | ||
buf.push('// Dynamic assets path override (webpack-runtime-public-path-plugin)'); | ||
buf.push('__webpack_require__.p = (' + runtimePublicPathStr + ') || __webpack_require__.p;'); | ||
return buf.join('\n'); | ||
if (compiler.hooks && compiler.hooks.thisCompilation) { | ||
compiler.hooks.thisCompilation.tap(this._name, function (compilation) { | ||
compilation.mainTemplate.plugin('require-extensions', function (source, chunk, hash) { | ||
return buf(runtimePublicPathStr, source) | ||
}); | ||
}); | ||
}); | ||
} else { | ||
compiler.plugin('this-compilation', function (compilation) { | ||
compilation.mainTemplate.plugin('require-extensions', function (source, chunk, hash) { | ||
return buf(runtimePublicPathStr, source) | ||
}); | ||
}); | ||
} | ||
}; | ||
module.exports = RuntimePublicPath; | ||
module.exports = RuntimePublicPath; |
{ | ||
"name": "webpack-runtime-public-path-plugin", | ||
"version": "1.1.1", | ||
"version": "1.1.2", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
2565
36
3