Add unit tests for absolute file names
This commit is contained in:
parent
e4e9555209
commit
a04434a225
|
|
@ -1,6 +1,11 @@
|
|||
Change History
|
||||
==============
|
||||
|
||||
v2.13.0
|
||||
----
|
||||
* Add support for absolute output file names
|
||||
* Add support for relative file names outside the output path
|
||||
|
||||
v2.12.0
|
||||
----
|
||||
* Basic Webpack 2.x support #225
|
||||
|
|
|
|||
5
index.js
5
index.js
|
|
@ -346,8 +346,11 @@ HtmlWebpackPlugin.prototype.htmlWebpackPluginAssets = function (compilation, chu
|
|||
|
||||
// Use the configured public path or build a relative path
|
||||
var publicPath = typeof compilation.options.output.publicPath !== 'undefined'
|
||||
// If a hard coded public path exists use it
|
||||
? compilation.mainTemplate.getPublicPath({hash: webpackStatsJson.hash})
|
||||
: path.relative(path.dirname(self.options.filename), '.').split(path.sep).join('/');
|
||||
// If no public path was set get a relative url path
|
||||
: path.relative(path.resolve(compilation.options.output.path, path.dirname(self.options.filename)), compilation.options.output.path)
|
||||
.split(path.sep).join('/');
|
||||
|
||||
if (publicPath.length && publicPath.substr(-1, 1) !== '/') {
|
||||
publicPath += '/';
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "html-webpack-plugin",
|
||||
"version": "2.12.0",
|
||||
"version": "2.13.0",
|
||||
"description": "Simplifies creation of HTML files to serve your webpack bundles",
|
||||
"main": "index.js",
|
||||
"files": [
|
||||
|
|
@ -11,6 +11,7 @@
|
|||
"scripts": {
|
||||
"prepublish": "npm run test",
|
||||
"pretest": "semistandard",
|
||||
"recompile": "node examples/rebuild.js",
|
||||
"test": "jasmine"
|
||||
},
|
||||
"repository": {
|
||||
|
|
|
|||
|
|
@ -578,10 +578,36 @@ describe('HtmlWebpackPlugin', function () {
|
|||
path: OUTPUT_DIR,
|
||||
filename: 'index_bundle.js'
|
||||
},
|
||||
plugins: [new HtmlWebpackPlugin({
|
||||
filename: path.resolve(OUTPUT_DIR, 'subfolder', 'test.html')
|
||||
})]
|
||||
}, ['<script src="../index_bundle.js"'], path.join('subfolder', 'test.html'), done);
|
||||
});
|
||||
|
||||
it('allows you to use an absolute output filename outside the output path', function (done) {
|
||||
testHtmlPlugin({
|
||||
entry: path.join(__dirname, 'fixtures/index.js'),
|
||||
output: {
|
||||
path: path.join(OUTPUT_DIR, 'app'),
|
||||
filename: 'index_bundle.js'
|
||||
},
|
||||
plugins: [new HtmlWebpackPlugin({
|
||||
filename: path.resolve(OUTPUT_DIR, 'test.html')
|
||||
})]
|
||||
}, ['<script src="index_bundle.js"'], 'test.html', done);
|
||||
}, ['<script src="app/index_bundle.js"'], 'test.html', done);
|
||||
});
|
||||
|
||||
it('allows you to use an relative output filename outside the output path', function (done) {
|
||||
testHtmlPlugin({
|
||||
entry: path.join(__dirname, 'fixtures/index.js'),
|
||||
output: {
|
||||
path: path.join(OUTPUT_DIR, 'app'),
|
||||
filename: 'index_bundle.js'
|
||||
},
|
||||
plugins: [new HtmlWebpackPlugin({
|
||||
filename: '../test.html'
|
||||
})]
|
||||
}, ['<script src="app/index_bundle.js"'], 'test.html', done);
|
||||
});
|
||||
|
||||
it('will try to use a relative name if the filename is in a subdirectory', function (done) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue