Skip to content

Commit

Permalink
Allow arbitrary extensions (not just .html files)
Browse files Browse the repository at this point in the history
  • Loading branch information
mikhuang committed Aug 6, 2016
1 parent 997318a commit aed389f
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 2 deletions.
4 changes: 3 additions & 1 deletion index.js
Expand Up @@ -41,7 +41,9 @@ StaticSiteGeneratorWebpackPlugin.prototype.apply = function(compiler) {
renderPromises = self.outputPaths.map(function(outputPath) {
var outputFileName = outputPath.replace(/^(\/|\\)/, ''); // Remove leading slashes for webpack-dev-server

if (!/\.(html?)$/i.test(outputFileName)) {
// If there is no extension, then assume it's a folder and add an index.html file
// (for a path like `/directory.with.dots/` then use `/directory.with.dots/index.html` )
if (!/\.(\w+)$/i.test(outputFileName)) {
outputFileName = path.join(outputFileName, 'index.html');
}

Expand Down
@@ -0,0 +1,5 @@
<html>
<body>
<h1>/foo.bar/index.html</h1>
</body>
</html>
@@ -0,0 +1,5 @@
<html>
<body>
<h1>/foo/bar/custom_ext.liquid</h1>
</body>
</html>
4 changes: 3 additions & 1 deletion test/success-cases/custom-file-names/webpack.config.js
Expand Up @@ -7,7 +7,9 @@ var template = ejs.compile(fs.readFileSync(__dirname + '/template.ejs', 'utf-8')
var paths = [
'/custom.html',
'/foo/custom.html',
'/foo/bar/custom.html'
'/foo/bar/custom.html',
'/foo/bar/custom_ext.liquid',
'/foo.bar/index.html',
];

module.exports = {
Expand Down

0 comments on commit aed389f

Please sign in to comment.