Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Always add a hash to the name of the files created by the default assets loaders #110

Merged
merged 2 commits into from
Jul 27, 2017

Conversation

Lyrkan
Copy link
Collaborator

@Lyrkan Lyrkan commented Jul 25, 2017

This PR modifies the configuration of the default assets loaders so a [hash] is always added to the output file names, even if versioning is disabled.

It basically prevents having two files with the same name (but in a different directory) overwriting each other during build.

This closes #73 and was further discussed in #103.

@@ -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)

@weaverryan
Copy link
Member

One minor comment - but this looks great - really nice job with the test!

@weaverryan
Copy link
Member

Thank you @Lyrkan! Test failure is from master and unrelated - I'll fix it :)

@weaverryan weaverryan merged commit d5cd482 into symfony:master Jul 27, 2017
weaverryan added a commit that referenced this pull request Jul 27, 2017
…fault assets loaders (Lyrkan)

This PR was squashed before being merged into the master branch (closes #110).

Discussion
----------

Always add a hash to the name of the files created by the default assets loaders

This PR modifies the configuration of the default assets loaders so a `[hash]` is always added to the output file names, even if versioning is disabled.

It basically prevents having two files with the same name (but in a different directory) overwriting each other during build.

This closes #73 and was further discussed in #103.

Commits
-------

d5cd482 Use [hash:8] for images and fonts filenames instead of [hash]
874235d Modify images/fonts loaders so a hash is always added to the name of output files
@Lyrkan Lyrkan deleted the always-add-hash-to-assets branch July 27, 2017 07:49
javiereguiluz added a commit to symfony/demo that referenced this pull request Sep 27, 2018
…n (bobdenotter)

This PR was merged into the master branch.

Discussion
----------

Updating Yarn dependencies, making build process work again

Some housekeeping on the Yarn / Encore build process:

 - Updated `symfony/encore` to `0.20.1` from `0.9.1`
 - Update a few other deps
 - Build process is now working again
 - Changed file naming strategy

Note: I replaced this

```
    .enableVersioning(false)
```

with this:

```
    .configureFilenames({
        js: '[name].js',
        images: 'images/[name].[ext]',
        fonts: 'fonts/[name].[ext]'
    })
```

I did this to keep the delta minimal. Since symfony/webpack-encore#110 `.enableVersioning(false)` is not doing what it says (for understandable reasons), but in this case I chose to keep the filenames without a versioning hash. If you think we should introduce filenames with version hashes instead, i'll happily update this PR.

Commits
-------

44d7267 Updating Yarn dependencies, making build process work again
sayjun0505 added a commit to sayjun0505/sym_proj that referenced this pull request Apr 16, 2023
…n (bobdenotter)

This PR was merged into the master branch.

Discussion
----------

Updating Yarn dependencies, making build process work again

Some housekeeping on the Yarn / Encore build process:

 - Updated `symfony/encore` to `0.20.1` from `0.9.1`
 - Update a few other deps
 - Build process is now working again
 - Changed file naming strategy

Note: I replaced this

```
    .enableVersioning(false)
```

with this:

```
    .configureFilenames({
        js: '[name].js',
        images: 'images/[name].[ext]',
        fonts: 'fonts/[name].[ext]'
    })
```

I did this to keep the delta minimal. Since symfony/webpack-encore#110 `.enableVersioning(false)` is not doing what it says (for understandable reasons), but in this case I chose to keep the filenames without a versioning hash. If you think we should introduce filenames with version hashes instead, i'll happily update this PR.

Commits
-------

44d7267 Updating Yarn dependencies, making build process work again
mwhorse46 added a commit to mwhorse46/sym_proj that referenced this pull request Apr 16, 2023
…n (bobdenotter)

This PR was merged into the master branch.

Discussion
----------

Updating Yarn dependencies, making build process work again

Some housekeeping on the Yarn / Encore build process:

 - Updated `symfony/encore` to `0.20.1` from `0.9.1`
 - Update a few other deps
 - Build process is now working again
 - Changed file naming strategy

Note: I replaced this

```
    .enableVersioning(false)
```

with this:

```
    .configureFilenames({
        js: '[name].js',
        images: 'images/[name].[ext]',
        fonts: 'fonts/[name].[ext]'
    })
```

I did this to keep the delta minimal. Since symfony/webpack-encore#110 `.enableVersioning(false)` is not doing what it says (for understandable reasons), but in this case I chose to keep the filenames without a versioning hash. If you think we should introduce filenames with version hashes instead, i'll happily update this PR.

Commits
-------

44d7267 Updating Yarn dependencies, making build process work again
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

File-loader not works with different images with same name
2 participants