add new feature: make we can extract css #94
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Similar with this pr and this feature
Sorry about that I am not familiar with this repo's test framework.But believe I have did some tests.
And sorry about that I am using windows,so I have to import some extra dependencies like
cross-env
,mkdirp
to make the command work.If you want to test,first you should
npm run build
in the root directory and then you should copy the generateddist
directory to this demo'snode_modules/babel-plugin-react-css-modules/dist
to make we can test.And second go to the demo's root directory,then executenpm run build
,it will call this plugin to generate result.And you can see whether the result is what I want.BTW,I create a new css file named
table2.css
to test whether we can extract more than one css files to just one file.There are 2 test which I have done:1.Test extract compiled all css to one file(note that in this mode you need to add
"removeImport": true
in the option because we have extracted our css to somewhere,so if you don't do this,we will can't find the corresponding css module.And in this mode you should not use--copy-files
because if you do,the css you copy is still origin css. i.e. it doesn't be processed):result:
And you can notice that although we import
table.css
twice(inAnonymouseStyleResolution.js
andRuntimeStyleResolution.js
),but the result css file doesn't has duplicate content.That's what we need.2.Test extract compiled css to their own component path of the src(note that in this mode you need to add the param
--copy-files
in your script config):result: