diff --git a/fixtures/images/symfony-logo.svg b/fixtures/images/symfony-logo.svg new file mode 100644 index 00000000..f10824ae --- /dev/null +++ b/fixtures/images/symfony-logo.svg @@ -0,0 +1 @@ +<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><path fill="#FFF" d="M12 .9C5.8.9.9 5.8.9 12a11 11 0 1 0 22.2 0A11 11 0 0 0 12 .9zm6.5 6c-.6 0-.9-.3-.9-.8 0-.2 0-.4.2-.6l.2-.4c0-.3-.5-.4-.6-.4-1.8.1-2.3 2.5-2.7 4.4l-.2 1c1 .2 1.8 0 2.2-.3.6-.4-.2-.7-.1-1.2.1-.3.5-.5.7-.6.5 0 .7.5.7.9 0 .7-1 1.8-3 1.8l-.6-.1-.6 2.4c-.4 1.6-.8 3.8-2.4 5.7-1.4 1.7-2.9 1.9-3.5 1.9-1.2 0-1.9-.6-2-1.5 0-.8.7-1.3 1.2-1.3.6 0 1.1.5 1.1 1s-.2.6-.4.6c-.1.1-.3.2-.3.4 0 .1.1.3.4.3.5 0 .8-.3 1.1-.5 1.2-.9 1.6-2.7 2.2-5.7l.1-.7.7-3.2c-.8-.6-1.3-1.4-2.4-1.7-.6-.1-1.1.1-1.5.5-.4.5-.2 1.1.2 1.5l.7.6c.7.8 1.2 1.6 1 2.5-.3 1.5-2 2.6-4 1.9-1.8-.6-2-1.8-1.8-2.5.2-.6.6-.7 1.1-.6.5.2.6.7.6 1.2l-.1.3c-.2.1-.3.3-.3.4-.1.4.4.6.7.7.7.3 1.6-.2 1.8-.8a1 1 0 0 0-.4-1.1l-.7-.8c-.4-.4-1.1-1.4-.7-2.6.1-.5.4-.9.7-1.3a4 4 0 0 1 2.8-.6c1.2.4 1.8 1.1 2.6 1.8.5-1.2 1-2.4 1.8-3.5.9-.9 1.9-1.6 3.1-1.7 1.3.2 2.2.7 2.2 1.6 0 .4-.2 1.1-.9 1.1z"/></svg> diff --git a/fixtures/js/import_svg.js b/fixtures/js/import_svg.js new file mode 100644 index 00000000..30958c4c --- /dev/null +++ b/fixtures/js/import_svg.js @@ -0,0 +1 @@ +import '../images/symfony-logo.svg'; diff --git a/test/functional.js b/test/functional.js index 3d5dc6ce..c2b491ac 100644 --- a/test/functional.js +++ b/test/functional.js @@ -81,6 +81,20 @@ describe('Functional tests using webpack', function() { }); describe('Basic scenarios.', () => { + it('Generates a correct manifest when images are imported from a js file', (done) => { + const config = createWebpackConfig('web/build', 'production'); + config.addEntry('svg', './js/import_svg'); + config.setPublicPath('/build'); + + testSetup.runWebpack(config, (webpackAssert) => { + webpackAssert.assertManifestPath( + 'build/images/symfony-logo.svg', + '/build/images/symfony-logo.579acd4f.svg' + ); + + done(); + }); + }); it('Builds a few simple entries file + manifest.json', (done) => { const config = createWebpackConfig('web/build', 'dev'); @@ -2124,6 +2138,7 @@ module.exports = { 'main.js', 'manifest.json', 'symfony_logo.png', + 'symfony-logo.svg', 'symfony_logo_alt.png', ]); @@ -2132,6 +2147,11 @@ module.exports = { '/build/main.js' ); + webpackAssert.assertManifestPath( + 'build/symfony-logo.svg', + '/build/symfony-logo.svg' + ); + webpackAssert.assertManifestPath( 'build/symfony_logo.png', '/build/symfony_logo.png' @@ -2171,6 +2191,7 @@ module.exports = { expect(path.join(config.outputPath, 'assets')).to.be.a.directory() .with.files([ + 'symfony-logo.svg', 'symfony_logo.png', 'symfony_logo_alt.png', 'Roboto.woff2', @@ -2181,6 +2202,11 @@ module.exports = { '/build/main.js' ); + webpackAssert.assertManifestPath( + 'build/assets/symfony-logo.svg', + '/build/assets/symfony-logo.svg' + ); + webpackAssert.assertManifestPath( 'build/assets/symfony_logo.png', '/build/assets/symfony_logo.png' @@ -2221,6 +2247,7 @@ module.exports = { expect(path.join(config.outputPath, 'images')).to.be.a.directory() .with.files([ + 'symfony-logo.579acd4f.svg', 'symfony_logo.91beba37.png', 'symfony_logo_alt.f880ba14.png', ]); @@ -2235,6 +2262,11 @@ module.exports = { '/build/main.js' ); + webpackAssert.assertManifestPath( + 'build/images/symfony-logo.svg', + '/build/images/symfony-logo.579acd4f.svg' + ); + webpackAssert.assertManifestPath( 'build/images/symfony_logo.png', '/build/images/symfony_logo.91beba37.png' @@ -2314,13 +2346,14 @@ module.exports = { 'runtime.518d4a5c.js', 'main.78f7d83e.js', 'manifest.json', + 'symfony-logo.579acd4f.svg', 'symfony_logo.91beba37.png', 'symfony_logo_alt.f880ba14.png', ]); webpackAssert.assertManifestPath( 'build/main.js', - '/build/main.78f7d83e.js' + '/build/main.31fd3788.js' ); } @@ -2329,6 +2362,11 @@ module.exports = { 'Roboto.woff2', ]); + webpackAssert.assertManifestPath( + 'build/symfony-logo.svg', + '/build/symfony-logo.579acd4f.svg' + ); + webpackAssert.assertManifestPath( 'build/symfony_logo.png', '/build/symfony_logo.91beba37.png' @@ -2407,6 +2445,7 @@ module.exports = { expect(path.join(config.outputPath, 'images')).to.be.a.directory() .with.files([ + 'symfony-logo.579acd4f.svg', 'symfony_logo.91beba37.png', 'symfony_logo_alt.f880ba14.png', ]); @@ -2421,6 +2460,11 @@ module.exports = { '/build/main.js' ); + webpackAssert.assertManifestPath( + 'build/images/symfony-logo.svg', + '/build/images/symfony-logo.579acd4f.svg' + ); + webpackAssert.assertManifestPath( 'build/images/symfony_logo.png', '/build/images/symfony_logo.91beba37.png'