8000 Add server-side CSS module hook. by izaakschroeder · Pull Request #14 · bootstarted/css-js-loader · GitHub
[go: up one dir, main page]

Skip to content

Add server-side CSS module hook. #14

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 1 commit into from
May 23, 2017
Merged

Conversation

izaakschroeder
Copy link
Contributor
@izaakschroeder izaakschroeder commented May 20, 2017

If you're using this loader on the server-side without doing webpack server side transforms you can use this hook to rewrite a module's exports to its equivalent CSS identifier. Because of how webpack works you will need to provide the context and local identifier name that was used to build the client-side CSS (typically process.cwd() is enough for the context). Example usage:

var css = require('css-js-loader/register');

css(process.cwd(), '[hash:base64]');

Note that I particularly don't condone this kind of thing (especially mucking about hooking node internals), but not all environments support server-side webpack either due to political or technical reasons so this will at least allow those users to play with this package.

@izaakschroeder izaakschroeder requested a review from 10xjs May 20, 2017 00:03
@izaakschroeder izaakschroeder force-pushed the server-side-hook branch 2 times, most recently from ca3494c to a409619 Compare May 20, 2017 00:07
If you're using this loader on the server-side without doing webpack server side transforms you can use this hook to rewrite a module's exports to its equivalent CSS identifier. Because of how webpack works you will need to provide the context and local identifier name that was used to build the client-side CSS (typically `process.cwd()` is enough for the context). Example usage:

```javascript
var css = require('css-js-loader/register');

css(process.cwd(), '[hash:base64]');
```

Note that I particularly don't condone this kind of thing (especially mucking about hooking node internals), but not all environments support server-side webpack either due to political or technical reasons so this will at least allow those users to play with this package.
@izaakschroeder izaakschroeder merged commit 7b50cc5 into master May 23, 2017
@izaakschroeder izaakschroeder deleted the server-side-hook branch May 23, 2017 00:30
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.

2 participants
0