Skip to content

Question for the authors #263

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

Closed
ScriptedAlchemy opened this issue Sep 7, 2018 · 2 comments
Closed

Question for the authors #263

ScriptedAlchemy opened this issue Sep 7, 2018 · 2 comments

Comments

@ScriptedAlchemy
Copy link
Contributor

Hey guys, I wanted to ask about the reasoning behind using a path for NS variable, instead of something static, like a string.

Heres the issue, lets say i have a build toolchain. The toolchain contains an import to mini-css, then elsewhere in the project core i also import mini-css.

What happens is i get an error saying this[NS] cant be resolved. When logging i discover that each instance has a new name which is used for loader context.

So the loader is looking for this[‘plugin-sass/node_modules/extract’], but the plugin is providing this[‘react-static/node_modules/extract']

I can change this by hard coding a string, and everything works perfectly across the instances.

const NS = '_extractCssChunks'; // works perfectly

Id like to know if there is any particular reason it was coded in this manner?
if i were to change the NS to something static in my project, would there any ramifications?

const NS = path.dirname(fs.realpathSync(__filename));

Appreciate your work and time.

@sokra

@michael-ciniawsky
Copy link
Member

michael-ciniawsky [07:50] #263

Is the NS necessary? Seems to be used as the module ‘type’ (module.type) (https://github.com/webpack-contrib/mini-css-extract-plugin/blob/master/src/index.js#L171-L173) which could be replaced by something like e.g text/css I assume, but also seems to be needed to create (?) the hash(es) (https://github.com/webpack-contrib/mini-css-extract-plugin/blob/master/src/index.js#L210-L216) which needs the resourcePath (?)

sokra [08:15] yep, I also thought about changing this to i. e. css/mini-extract. This would also work better with the new module type filters in splitChunks

If you want to give it a try feel free to send a PR :)

@ScriptedAlchemy
Copy link
Contributor Author

Awesome, im currently implementing this into extract-css-chunks-webpack-plugin, which was based of mini-css. Im testing this with some assistance from the React Static team.

Seems stable but want to wait for a couple thousand downloads before I make any changes here.

Closing this as its a duplicate, sorrrryyyy

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

No branches or pull requests

2 participants