Socket
Socket
Sign inDemoInstall

html-webpack-plugin

Package Overview
Dependencies
1
Maintainers
1
Versions
138
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.0.0 to 1.0.1

27

index.js

@@ -24,14 +24,19 @@ var fs = require('fs');

var htmlTemplateContent = fs.readFileSync(templateFile, 'utf8');
var html = tmpl(htmlTemplateContent, templateParams);
var outputFilename = self.options.filename || 'index.html';
compiler.assets[outputFilename] = {
source: function() {
return html;
},
size: function() {
return html.length;
fs.readFile(templateFile, 'utf8', function(err, htmlTemplateContent) {
if (err) {
compiler.errors.push(new Error('HtmlWebpackPlugin: Unable to read HTML template "' + templateFile + '"'));
} else {
var html = tmpl(htmlTemplateContent, templateParams);
var outputFilename = self.options.filename || 'index.html';
compiler.assets[outputFilename] = {
source: function() {
return html;
},
size: function() {
return html.length;
}
};
}
};
callback();
callback();
});
});

@@ -38,0 +43,0 @@ };

{
"name": "html-webpack-plugin",
"version": "1.0.0",
"version": "1.0.1",
"description": "Simplifies creation of HTML files to serve your webpack bundles",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -9,3 +9,3 @@ var path = require('path');

function testHtmlPlugin(webpackConfig, expectedResults, done, outputFile) {
function testHtmlPlugin(webpackConfig, expectedResults, outputFile, done) {
outputFile = outputFile || 'index.html';

@@ -41,3 +41,3 @@ webpack(webpackConfig, function(err, stats) {

plugins: [new HtmlWebpackPlugin()]
}, ['<script src="index_bundle.js"'], done);
}, ['<script src="index_bundle.js"'], null, done);

@@ -57,3 +57,3 @@ });

plugins: [new HtmlWebpackPlugin()]
}, ['<script src="util_bundle.js"', '<script src="app_bundle.js"'], done);
}, ['<script src="util_bundle.js"', '<script src="app_bundle.js"'], null, done);
});

@@ -72,3 +72,3 @@

},
['<script src="app_bundle.js"', 'Some unique text'], done);
['<script src="app_bundle.js"', 'Some unique text'], null, done);
});

@@ -85,3 +85,3 @@

plugins: [new HtmlWebpackPlugin()]
}, ['<script src="index_bundle.js"'], done);
}, ['<script src="index_bundle.js"'], null, done);
});

@@ -97,3 +97,3 @@

plugins: [new HtmlWebpackPlugin()]
}, [/<script src="index_bundle_[0-9a-f]+\.js"/], done);
}, [/<script src="index_bundle_[0-9a-f]+\.js"/], null, done);
});

@@ -110,3 +110,3 @@

plugins: [new HtmlWebpackPlugin()]
}, ['<script src="http://cdn.example.com/assets/index_bundle.js"'], done);
}, ['<script src="http://cdn.example.com/assets/index_bundle.js"'], null, done);
});

@@ -122,3 +122,3 @@

plugins: [new HtmlWebpackPlugin()]
}, ['<script src="assets/index_bundle.js"'], done);
}, ['<script src="assets/index_bundle.js"'], null, done);
});

@@ -135,3 +135,3 @@

plugins: [new HtmlWebpackPlugin()]
}, ['<script src="http://cdn.example.com/assets/index_bundle.js"'], done);
}, ['<script src="http://cdn.example.com/assets/index_bundle.js"'], null, done);
});

@@ -147,3 +147,3 @@

plugins: [new HtmlWebpackPlugin({title: 'My Cool App'})]
}, ['<title>My Cool App</title>'], done);
}, ['<title>My Cool App</title>'], null, done);
});

@@ -159,3 +159,3 @@

plugins: [new HtmlWebpackPlugin({filename: 'test.html'})]
}, ['<script src="index_bundle.js"'], done, 'test.html');
}, ['<script src="index_bundle.js"'], 'test.html', done);
});

@@ -171,3 +171,3 @@

plugins: [new HtmlWebpackPlugin({filename: 'assets/test.html'})]
}, ['<script src="index_bundle.js"'], done, 'assets/test.html');
}, ['<script src="index_bundle.js"'], 'assets/test.html', done);
});

@@ -189,3 +189,3 @@

]
}, ['<script src="index_bundle.js"'], done);
}, ['<script src="index_bundle.js"'], null, done);

@@ -195,2 +195,17 @@ expect(fs.existsSync(path.join(__dirname, 'fixtures/test.html'))).toBe(true);

it('registers a webpack error if the template cannot be opened', function(done) {
webpack({
entry: path.join(__dirname, 'fixtures/index.js'),
output: {
path: OUTPUT_DIR,
filename: 'index_bundle.js'
},
plugins: [new HtmlWebpackPlugin({template: 'fixtures/does_not_exist.html'})]
}, function(err, stats) {
expect(stats.hasErrors()).toBe(true);
expect(stats.toJson().errors[0]).toContain('HtmlWebpackPlugin');
done();
});
});
});
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc