Skip to content
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

fs option #143

Closed
frux opened this issue Oct 27, 2016 · 7 comments
Closed

fs option #143

frux opened this issue Oct 27, 2016 · 7 comments

Comments

@frux
Copy link

frux commented Oct 27, 2016

I build my app for client and server. But I can't require rebuilded server scripts because of memory-fs. Can you give me availability to use custom file-system library (e.g. fs)?

@SpaceK33z
Copy link
Member

webpack-dev-middleware is specifically made to handle and serve in-memory files. I don't understand your use case, could you explain that a bit more?

@otarim
Copy link

otarim commented Oct 29, 2016

@SpaceK33z sometimes i need to inject some config into process file during dev stage. With memory-fs i can't access files pass through middleware

@SpaceK33z
Copy link
Member

@otarim, is the config purely for the html files? You could use something like html-webpack-plugin and pass config parameters to the plugin. In the html file you could then display those with underscore templates.

E.g. in your webpack config, add new HtmlWebPackPlugin({ template: 'src/my-index.html', myConfig: 'blabla' }). And then in src/my-index.html, include something like this: <%=htmlWebpackPlugin.options.myConfig%>.

@SpaceK33z
Copy link
Member

Also see #88.

@SimeonC
Copy link

SimeonC commented Dec 19, 2016

Hey, just came across this issue myself, so I found that the fs is exposed on the middleware here:

webpackDevMiddleware.fileSystem = context.fs;

And it's set here:

context.fs = fs;

The problem I've found is that we can access the fs for the first render, but as the middleware is essentially setting an object reference - it doesn't update when we change it so I can't get a reference to the new FS. My use case is building a custom dev server for node-tailor which requires me to send the main js bundle through in a custom header. I have to restart the process to get the new file being sent through. This would be fixed by using a function to get the fs rather than relying on the object reference.

EDIT Nvm - realised I was using v1.8 - this is fixed in v1.9. (Possibly wasn't broken in 1.8 but who knows!!!)

@tconroy
Copy link

tconroy commented May 2, 2017

hi @SimeonC - I'm trying to do an fs.readFileSync to read in a file from dev-middleware memory (I detailed my use case more over in #190). Can you elaborate how you got it working for your use case? I'm just trying to read-in a css file ( built by webpack ) into a node server environment so I can inject it in responses.

@shellscape
Copy link
Contributor

closing given the discussion and apparent resolution and issue age. please request a reopen if needs be.

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

6 participants