Skip to content

Commit 58c3914

Browse files
committed
small modification to multi output functionality
1 parent 6feb1bf commit 58c3914

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

lib/plugin.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,9 +85,10 @@ module.exports = class SpikeWebpackPlugin {
8585
if (dep._outputMultiple) {
8686
// if we have an outputMultiple flag, that means more than one
8787
// output (shocking, i know)
88-
const sources = JSON.parse(src)
88+
const sources = JSON.parse(String(src))
8989
for (let k in sources) {
90-
const multiOutPath = outputPath.replace(/\.html/, `.${k}.html`)
90+
let multiOutPath = k
91+
if (!k.match(/\.html$/)) multiOutPath += '.html'
9192
compilation.assets[multiOutPath] = {
9293
source: () => { return sources[k] },
9394
size: () => { return sources[k].length }

test/multi.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@ const fs = require('fs')
44
const exp = require('reshape-expressions')
55
const {compileFixture} = require('./_helpers')
66

7-
test('emits compile errors correctly', (t) => {
7+
test('compiles multi output templates correctly', (t) => {
88
return compileFixture(t, 'multi', {
99
reshape: {
1010
plugins: [exp()],
1111
multi: [
12-
{ locals: { greeting: 'hello' }, name: 'en' },
13-
{ locals: { greeting: 'hola' }, name: 'es' }
12+
{ locals: { greeting: 'hello' }, name: 'index.en' },
13+
{ locals: { greeting: 'hola' }, name: 'index.es.html' }
1414
]
1515
}
1616
}).then(({res, publicPath}) => {

0 commit comments

Comments
 (0)