Raise an error if both template and templateContent options are used together
This commit is contained in:
parent
0b89ce7d20
commit
58d173c3d0
5
index.js
5
index.js
|
|
@ -18,7 +18,10 @@ HtmlWebpackPlugin.prototype.apply = function(compiler) {
|
|||
|
||||
var outputFilename = self.options.filename || 'index.html';
|
||||
|
||||
if (self.options.templateContent) {
|
||||
if (self.options.templateContent && self.options.template) {
|
||||
compiler.errors.push(new Error('HtmlWebpackPlugin: cannot specify both template and templateContent options'));
|
||||
callback();
|
||||
} else if (self.options.templateContent) {
|
||||
self.emitHtml(compiler, self.options.templateContent, templateParams, outputFilename);
|
||||
callback();
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -83,6 +83,23 @@ describe('HtmlWebpackPlugin', function() {
|
|||
['<script src="app_bundle.js"'], null, done);
|
||||
});
|
||||
|
||||
it('registers a webpack error both template and template content are specified', function(done) {
|
||||
webpack({
|
||||
entry: path.join(__dirname, 'fixtures/index.js'),
|
||||
output: {
|
||||
path: OUTPUT_DIR,
|
||||
filename: 'index_bundle.js'
|
||||
},
|
||||
plugins: [new HtmlWebpackPlugin({
|
||||
template: path.join(__dirname, 'fixtures/test.html'),
|
||||
templateContent: 'whatever'
|
||||
})]
|
||||
}, function(err, stats) {
|
||||
expect(stats.hasErrors()).toBe(true);
|
||||
expect(stats.toJson().errors[0]).toContain('HtmlWebpackPlugin');
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('works with source maps', function(done) {
|
||||
testHtmlPlugin({
|
||||
|
|
|
|||
Loading…
Reference in New Issue