Skip to content

Add the hashPrefix option #26

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

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
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
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ npm install --save-dev babel-plugin-css-modules-transform
"generateScopedName": "[name]__[local]___[hash:base64:5]", // in case you don't want to use a function
"generateScopedName": "./path/to/module-exporting-a-function.js", // in case you want to use a function
"generateScopedName": "npm-module-name",
"hashPrefix": "string",
"ignore": "*css",
"ignore": "./path/to/module-exporting-a-function-or-regexp.js",
"preprocessCss": "./path/to/module-exporting-a-function.js",
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
},
"homepage": "https://github.com/michalkvasnicak/babel-plugin-css-modules-transform#readme",
"dependencies": {
"css-modules-require-hook": "^4.0.2",
"css-modules-require-hook": "^4.0.3",
"mkdirp": "^0.5.1"
},
"devDependencies": {
Expand Down
15 changes: 15 additions & 0 deletions src/options_resolvers/hashPrefix.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { isString } from '../utils';

/**
* Resolves hashPrefix option for css-modules-require-hook
*
* @param {*} value
* @returns {String}
*/
export default function hashPrefix(value/* , currentConfig */) {
if (!isString(value)) {
throw new Error(`Configuration 'hashPrefix' is not a string`);
}

return value;
}
1 change: 1 addition & 0 deletions src/options_resolvers/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ export { default as camelCase } from './camelCase';
export { default as createImportedName } from './createImportedName';
export { default as devMode } from './devMode';
export { default as generateScopedName } from './generateScopedName';
export { default as hashPrefix } from './hashPrefix';
export { default as ignore } from './ignore';
export { default as mode } from './mode';
export { default as prepend } from './prepend';
Expand Down
2 changes: 1 addition & 1 deletion src/options_resolvers/mode.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { isString } from '../utils';
* Resolves mode option for css-modules-require-hook
*
* @param {*} value
* @returns {boolean}
* @returns {String}
*/
export default function mode(value/* , currentConfig */) {
if (!isString(value)) {
Expand Down
4 changes: 2 additions & 2 deletions src/options_resolvers/rootDir.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ import { statSync } from 'fs';
import { isString } from '../utils';

/**
* Resolves mode option for css-modules-require-hook
* Resolves rootDir option for css-modules-require-hook
*
* @param {*} value
* @returns {boolean}
* @returns {String}
*/
export default function rootDir(value/* , currentConfig */) {
if (!isString(value)) {
Expand Down
13 changes: 13 additions & 0 deletions test/options_resolvers/hashPrefix.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { expect } from 'chai';

import hashPrefix from '../../src/options_resolvers/hashPrefix';

describe('options_resolvers/hashPrefix', () => {
it('should throw if hashPrefix value is not a string', () => {
expect(
() => hashPrefix(null)
).to.throw();

expect(hashPrefix('hashPrefix')).to.be.equal('hashPrefix');
});
});