mirror of
https://github.com/react-webpack-generators/generator-react-webpack.git
synced 2025-12-08 18:01:59 +00:00
Added support for cssmodules when setting up projects. closes #265
This commit is contained in:
parent
90f516c149
commit
b581e5bd02
@ -104,6 +104,14 @@ class AppGenerator extends Generators.Base {
|
||||
}
|
||||
}
|
||||
|
||||
// Add cssmodules if enabled
|
||||
const cssmoduleConfig = utils.config.getChoiceByKey('cssmodules', 'cssmodules');
|
||||
if(this.cssmodules && cssmoduleConfig && cssmoduleConfig.packages) {
|
||||
for(let dependency of cssmoduleConfig.packages) {
|
||||
packageSettings.dependencies[dependency.name] = dependency.version;
|
||||
}
|
||||
}
|
||||
|
||||
this.fs.writeJSON(this.destinationPath('package.json'), packageSettings);
|
||||
}
|
||||
|
||||
|
||||
@ -23,8 +23,7 @@ const beforeLoad = (prompts) => {
|
||||
'skip-welcome-message': true,
|
||||
'skip-install': true
|
||||
})
|
||||
.withPrompts
|
||||
(prompts)
|
||||
.withPrompts(prompts)
|
||||
.on('ready', function(instance) {
|
||||
generator = instance;
|
||||
})
|
||||
@ -61,6 +60,12 @@ describe('react-webpack:app', () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe('configuring', () => {
|
||||
it('should add css module support', () => {
|
||||
assert.fileContent('package.json', 'react-css-modules');
|
||||
});
|
||||
});
|
||||
|
||||
describe('#createFiles', () => {
|
||||
|
||||
it('should generate dot files', () => {
|
||||
@ -120,6 +125,44 @@ describe('react-webpack:app', () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe('react-webpack:app without cssmodules support', () => {
|
||||
|
||||
let prompts = {};
|
||||
for(let p of defaultPrompts) {
|
||||
prompts[p.name] = p.default;
|
||||
}
|
||||
prompts.cssmodules = false;
|
||||
|
||||
before(() => {
|
||||
return beforeLoad(prompts);
|
||||
});
|
||||
|
||||
describe('#config', () => {
|
||||
|
||||
it('should set the generatedWith key to the current generator major version', () => {
|
||||
expect(generator.config.get('generatedWithVersion')).to.equal(4);
|
||||
});
|
||||
|
||||
it('should use "css" as default style language', () => {
|
||||
expect(generator.config.get('style')).to.equal('css');
|
||||
});
|
||||
|
||||
it('should not use "css modules"', () => {
|
||||
expect(generator.config.get('cssmodules')).to.be.false;
|
||||
});
|
||||
|
||||
it('should not enable "PostCSS" by default', () => {
|
||||
expect(generator.config.get('postcss')).to.be.false;
|
||||
});
|
||||
});
|
||||
|
||||
describe('configuring', () => {
|
||||
it('should add no cssmodule support', () => {
|
||||
assert.noFileContent('package.json', 'react-css-modules');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('react-webpack:app with PostCSS support', () => {
|
||||
|
||||
let prompts = {};
|
||||
|
||||
@ -51,6 +51,17 @@
|
||||
}
|
||||
]
|
||||
},
|
||||
"cssmodules": {
|
||||
"options": [
|
||||
{
|
||||
"name": "cssmodules",
|
||||
"value": "cssmodules",
|
||||
"packages": [
|
||||
{ "name": "react-css-modules", "version": "^3.7.10" }
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
"style": {
|
||||
"options": [
|
||||
{
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user