diff --git a/lib/util.js b/lib/util.js index b6ff058..4d831bd 100644 --- a/lib/util.js +++ b/lib/util.js @@ -144,7 +144,7 @@ function generatePreviewHead(parsedConfig) { continue; } doc.push(`<${key} ${objectToHTMLAttributes(value)}>`); - if(value.src.indexOf('assets/vendor.js') > -1) { + if(value.src.match(/assets\/vendor[^.]*\.js/)) { // make sure we push this right after vendor to ensure the application does not bind to the window. doc.push(''); } diff --git a/node-tests/__snapshots__/util.test.js.snap b/node-tests/__snapshots__/util.test.js.snap index 2eaa81b..559e97b 100644 --- a/node-tests/__snapshots__/util.test.js.snap +++ b/node-tests/__snapshots__/util.test.js.snap @@ -15,6 +15,16 @@ exports[`util @generatePreviewHead should work with file created with \`ember bu " `; +exports[`util @generatePreviewHead should work with file created with \`ember build\` in production env 1`] = ` +" + + + + + +" +`; + exports[`util @generatePreviewHead should work with file created with \`ember serve\` (should append livereload pointing at serve instance) 1`] = ` " diff --git a/node-tests/fixtures/build-production.html b/node-tests/fixtures/build-production.html new file mode 100644 index 0000000..2d27076 --- /dev/null +++ b/node-tests/fixtures/build-production.html @@ -0,0 +1,25 @@ + + + + + BeforeStorybook + + + + + + + + + + + + + + + + + + + + diff --git a/node-tests/util.test.js b/node-tests/util.test.js index a72d62c..7925876 100644 --- a/node-tests/util.test.js +++ b/node-tests/util.test.js @@ -186,6 +186,14 @@ Object { expect(generatePreviewHead(parse(fileContent))).toMatchSnapshot() }) + it('should work with file created with `ember build` in production env', () => { + expect.assertions(1); + + const fileContent = fs.readFileSync(path.resolve(__dirname, 'fixtures', 'build-production.html'), 'utf8'); + + expect(generatePreviewHead(parse(fileContent))).toMatchSnapshot() + }) + it('should work with file created with `ember serve` (should append livereload pointing at serve instance)', () => { expect.assertions(1); diff --git a/package.json b/package.json index e13e499..d5f66e3 100644 --- a/package.json +++ b/package.json @@ -31,8 +31,8 @@ "test:ember-compatibility": "ember try:each" }, "devDependencies": { - "@embroider/test-setup": "^1.8.3", "@ember/optional-features": "^1.3.0", + "@ember/string": "^3.1.1", "@ember/test-helpers": "^2.8.0", "@embroider/test-setup": "^2.0.2", "babel-eslint": "^10.1.0",