Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions fixtures/css/same_filename.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
h4 {
background: top left url('./../images/symfony_logo.png') no-repeat;
}

h5 {
background: top left url('./../images/same_filename/symfony_logo.png') no-repeat;
}

@font-face {
font-family: 'Roboto';
src: url('./../fonts/Roboto.woff2') format('woff2');
}

@font-face {
font-family: 'Roboto2';
src: url('./../fonts/same_filename/Roboto.woff2') format('woff2');
}
Binary file added fixtures/fonts/same_filename/Roboto.woff2
Binary file not shown.
Binary file added fixtures/images/same_filename/symfony_logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions lib/config-generator.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,15 +127,15 @@ class ConfigGenerator {
test: /\.(png|jpg|jpeg|gif|ico|svg)$/,
loader: 'file-loader',
options: {
name: `images/[name]${this.webpackConfig.useVersioning ? '.[hash]' : ''}.[ext]`,
name: 'images/[name].[hash].[ext]',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you think about using a shorter hash - like [hash:8]? The longer seems overkill... I should have done this originally.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done, no idea what's up with AppVeyor though (same thing for #103)

publicPath: this.webpackConfig.getRealPublicPath()
}
},
{
test: /\.(woff|woff2|ttf|eot|otf)$/,
loader: 'file-loader',
options: {
name: `fonts/[name]${this.webpackConfig.useVersioning ? '.[hash]' : ''}.[ext]`,
name: 'fonts/[name].[hash].[ext]',
publicPath: this.webpackConfig.getRealPublicPath()
}
},
Expand Down
76 changes: 62 additions & 14 deletions test/functional.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ describe('Functional tests using webpack', function() {
'main.js',
'font.css',
'bg.css',
'fonts/Roboto.woff2',
'images/symfony_logo.png',
'fonts/Roboto.9896f773628188b649ed5824fa363290.woff2',
'images/symfony_logo.ea1ca6f7f3719118f301a5cfcb1df3c0.png',
'manifest.json'
]);

Expand All @@ -87,11 +87,11 @@ describe('Functional tests using webpack', function() {
);
webpackAssert.assertManifestPath(
'build/fonts/Roboto.woff2',
'/build/fonts/Roboto.woff2'
'/build/fonts/Roboto.9896f773628188b649ed5824fa363290.woff2'
);
webpackAssert.assertManifestPath(
'build/images/symfony_logo.png',
'/build/images/symfony_logo.png'
'/build/images/symfony_logo.ea1ca6f7f3719118f301a5cfcb1df3c0.png'
);

done();
Expand Down Expand Up @@ -119,11 +119,11 @@ describe('Functional tests using webpack', function() {

webpackAssert.assertOutputFileContains(
'bg.css',
'http://localhost:8090/assets/images/symfony_logo.png'
'http://localhost:8090/assets/images/symfony_logo.ea1ca6f7f3719118f301a5cfcb1df3c0.png'
);
webpackAssert.assertOutputFileContains(
'font.css',
'http://localhost:8090/assets/fonts/Roboto.woff2'
'http://localhost:8090/assets/fonts/Roboto.9896f773628188b649ed5824fa363290.woff2'
);
// manifest file has CDN in value
webpackAssert.assertManifestPath(
Expand Down Expand Up @@ -172,7 +172,7 @@ describe('Functional tests using webpack', function() {

webpackAssert.assertOutputFileContains(
'bg.css',
'http://localhost:8090/assets/images/symfony_logo.png'
'http://localhost:8090/assets/images/symfony_logo.ea1ca6f7f3719118f301a5cfcb1df3c0.png'
);
// manifest file has CDN in value
webpackAssert.assertManifestPath(
Expand Down Expand Up @@ -323,28 +323,76 @@ describe('Functional tests using webpack', function() {

expect(path.join(config.outputPath, 'images')).to.be.a.directory()
.with.files([
'symfony_logo.png'
'symfony_logo.ea1ca6f7f3719118f301a5cfcb1df3c0.png'
]
);

expect(path.join(config.outputPath, 'fonts')).to.be.a.directory()
.with.files([
'Roboto.woff2'
'Roboto.9896f773628188b649ed5824fa363290.woff2'
]
);

webpackAssert.assertOutputFileContains(
'bg.css',
'/build/images/symfony_logo.png'
'/build/images/symfony_logo.ea1ca6f7f3719118f301a5cfcb1df3c0.png'
);

webpackAssert.assertOutputFileContains(
'font.css',
'/build/fonts/Roboto.woff2'
'/build/fonts/Roboto.9896f773628188b649ed5824fa363290.woff2'
);

done();
});
});

it('two fonts or images with the same filename should not output a single file', (done) => {
const config = createWebpackConfig('www/build', 'dev');
config.setPublicPath('/build');
config.addStyleEntry('styles', './css/same_filename.css');
config.enableSassLoader();

testSetup.runWebpack(config, (webpackAssert) => {
expect(config.outputPath).to.be.a.directory()
.with.files([
'styles.css',
'manifest.json'
]
);

expect(path.join(config.outputPath, 'images')).to.be.a.directory()
.with.files([
'symfony_logo.ea1ca6f7f3719118f301a5cfcb1df3c0.png',
'symfony_logo.f27119c20951b473f2de80c000d60fa8.png'
]
);

expect(path.join(config.outputPath, 'fonts')).to.be.a.directory()
.with.files([
'Roboto.9896f773628188b649ed5824fa363290.woff2',
'Roboto.3c37aa69cd77e6a53a067170fa8fe2e9.woff2'
]
);

webpackAssert.assertOutputFileContains(
'font.css',
'/build/fonts/Roboto.woff2'
'styles.css',
'/build/images/symfony_logo.ea1ca6f7f3719118f301a5cfcb1df3c0.png'
);

webpackAssert.assertOutputFileContains(
'styles.css',
'/build/images/symfony_logo.f27119c20951b473f2de80c000d60fa8.png'
);

webpackAssert.assertOutputFileContains(
'styles.css',
'/build/fonts/Roboto.9896f773628188b649ed5824fa363290.woff2'
);

webpackAssert.assertOutputFileContains(
'styles.css',
'/build/fonts/Roboto.3c37aa69cd77e6a53a067170fa8fe2e9.woff2'
);

done();
Expand Down Expand Up @@ -687,7 +735,7 @@ module.exports = {
expect(config.outputPath).to.be.a.directory().with.deep.files([
'main.js',
'main.css',
'images/logo.png',
'images/logo.82b9c7a5a3f405032b1db71a25f67021.png',
'manifest.json'
]);

Expand Down