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

Add Encore.configureFilenames() method to the public API #137

Merged
merged 1 commit into from
Aug 16, 2017

Conversation

Lyrkan
Copy link
Collaborator

@Lyrkan Lyrkan commented Aug 10, 2017

This PR adds the Encore.configureFilenames() method to the public API (fixes #125).

Example:

Encore.configureFilenames({
    js: '[name].[chunkhash].js',
    css: '[name].[contenthash].css',
    images: 'images/[name].[hash:8].[ext]',
    fonts: 'fonts/[name].[hash:8].[ext]'
});

If one key is defined in the first parameter it will be used for the filenames of the related category.
If it isn't the behavior will stay the same as before.

For now I kept the old naming strategies as the default values. We could eventually change that following the discussion in #136.

Copy link
Member

@weaverryan weaverryan left a comment

Choose a reason for hiding this comment

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

This looks awesome! The only change I had was with a small comment... I'll just make that after merging - no sense it not merging due to that :)

* });
*
* Only the filenames defined in the first parameter
* of this method will be modified.
Copy link
Member

Choose a reason for hiding this comment

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

How about:

It's safe to omit a key (e.g. css): the default naming strategy
will be used for those file types.

* If you are using Encore.enableVersioning()
* make sure that your "js" filenames contain
* "[chunkhash]" and your "css" filenames contain
* "[contenthash]".
Copy link
Member

Choose a reason for hiding this comment

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

nice

if (validKeys.indexOf(key) === -1) {
throw new Error(`"${key}" is not a valid key for configureFilenames(). Valid keys: ${validKeys.join(', ')}.`);
}
}
Copy link
Member

Choose a reason for hiding this comment

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

well, I love this ;)

@weaverryan
Copy link
Member

Thank you @Lyrkan!

@weaverryan weaverryan merged commit 0c9a8fe into symfony:master Aug 16, 2017
weaverryan added a commit that referenced this pull request Aug 16, 2017
… (Lyrkan)

This PR was merged into the master branch.

Discussion
----------

Add Encore.configureFilenames() method to the public API

This PR adds the `Encore.configureFilenames()` method to the public API (fixes #125).

**Example:**

```js
Encore.configureFilenames({
    js: '[name].[chunkhash].js',
    css: '[name].[contenthash].css',
    images: 'images/[name].[hash:8].[ext]',
    fonts: 'fonts/[name].[hash:8].[ext]'
});
```

If one key is defined in the first parameter it will be used for the filenames of the related category.
If it isn't the behavior will stay the same as before.

For now I kept the old naming strategies as the default values. We could eventually change that following the discussion in #136.

Commits
-------

0c9a8fe Add Encore.configureFilenames() method to the public API
@Seikyo
Copy link

Seikyo commented Aug 17, 2017

Thank you for your time and the feature @Lyrkan @weaverryan

@Lyrkan Lyrkan deleted the add-configure-filenames branch August 17, 2017 13:07
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.

Versioning file format configuration
3 participants