Skip to content

Commit 389acce

Browse files
committed
Add the hashPrefix option
1 parent fe80fc5 commit 389acce

File tree

4 files changed

+30
-1
lines changed

4 files changed

+30
-1
lines changed

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ npm install --save-dev babel-plugin-css-modules-transform
7070
"generateScopedName": "[name]__[local]___[hash:base64:5]", // in case you don't want to use a function
7171
"generateScopedName": "./path/to/module-exporting-a-function.js", // in case you want to use a function
7272
"generateScopedName": "npm-module-name",
73+
"hashPrefix": "string",
7374
"ignore": "*css",
7475
"ignore": "./path/to/module-exporting-a-function-or-regexp.js",
7576
"preprocessCss": "./path/to/module-exporting-a-function.js",

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
},
2626
"homepage": "https://github.com/michalkvasnicak/babel-plugin-css-modules-transform#readme",
2727
"dependencies": {
28-
"css-modules-require-hook": "^4.0.2",
28+
"css-modules-require-hook": "^4.0.3",
2929
"mkdirp": "^0.5.1"
3030
},
3131
"devDependencies": {

src/options_resolvers/hashPrefix.js

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import { isString } from '../utils';
2+
3+
/**
4+
* Resolves hashPrefix option for css-modules-require-hook
5+
*
6+
* @param {*} value
7+
* @returns {boolean}
8+
*/
9+
export default function hashPrefix(value/* , currentConfig */) {
10+
if (!isString(value)) {
11+
throw new Error(`Configuration 'hashPrefix' is not a string`);
12+
}
13+
14+
return value;
15+
}
+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import { expect } from 'chai';
2+
3+
import hashPrefix from '../../src/options_resolvers/hashPrefix';
4+
5+
describe('options_resolvers/hashPrefix', () => {
6+
it('should throw if hashPrefix value is not a string', () => {
7+
expect(
8+
() => hashPrefix(null)
9+
).to.throw();
10+
11+
expect(hashPrefix('hashPrefix')).to.be.equal('hashPrefix');
12+
});
13+
});

0 commit comments

Comments
 (0)