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

Webpack creating json.gzip files in app root when using docker #483

Closed
Grmiade opened this issue Aug 24, 2016 · 11 comments
Closed

Webpack creating json.gzip files in app root when using docker #483

Grmiade opened this issue Aug 24, 2016 · 11 comments

Comments

@Grmiade
Copy link

Grmiade commented Aug 24, 2016

webpack/webpack#2223 (comment)

Should we use cacheDirectory to fix it?

@gaearon
Copy link
Contributor

gaearon commented Aug 24, 2016

We already have cacheDirectory: true, isn't that supposed to use the system temp directory?

cc @hzoo

@hzoo
Copy link

hzoo commented Aug 24, 2016

Sorry, I actually haven't used that option before, code is here

If the value is blank (loader: 'babel-loader?cacheDirectory') the loader will use the default OS temporary file directory.

@thangngoc89
Copy link
Contributor

This is due to how npm works when run as root user
See MoOx/phenomic#545

I suggest using this package to avoid this problem https://github.com/avajs/find-cache-dir

@gaearon
Copy link
Contributor

gaearon commented Aug 25, 2016

What are the relevant packages we need to send PRs to?
Is it babel-loader?

@thangngoc89 Would you be interested in doing so?

@thangngoc89
Copy link
Contributor

thangngoc89 commented Aug 25, 2016

We need to setup it up in babel-loader setting.

const cacheDir = findCacheDir({name: 'create-react-app'})

// webpack loaders config
babel-loader?cacheDirectory=cacheDir

From now on, babel-loader will use ./node_modules/.cache/create-react-app as it caches folder

If you accept this solution, I would be happy to send out a PR

@gaearon
Copy link
Contributor

gaearon commented Aug 25, 2016

Sounds good if you can make it work. Ideally I’d avoid using node_modules for cache though because people are going to measure it and complain CRA has too many dependencies. 😄

@zelenin
Copy link

zelenin commented Sep 6, 2016

Hey. What about this issue?

@thangngoc89
Copy link
Contributor

@zelenin Sorry, I forgot this. This will be my first thing to do tomorrow. For now, don't run this in docker with root user.

@gaearon
Copy link
Contributor

gaearon commented Sep 17, 2016

Why didn’t we send a PR to babel-loader itself to use findCacheDir({ name: 'babel-loader' }) by default? Wouldn’t that make more sense than special-casing it here?

@gaearon gaearon reopened this Sep 17, 2016
fson added a commit to fson/babel-loader that referenced this issue Sep 18, 2016
Set the default cache directory as the
[common cache directory](https://github.com/avajs/find-cache-dir),
`./node_modules/.cache/babel-loader`.

Previously, when `cacheDirectory` was set to `true`, babel-loader
tried to use the operating system's temporary directory as a cache
directory.

However, when running npm scripts as the root user,
[npm overrides the TMPDIR environment variable](npm/npm#4531).
This caused the cache files to be created in the project folder itself,
for example when using Docker: facebook/create-react-app#483.
fson added a commit to fson/babel-loader that referenced this issue Sep 18, 2016
Set the default cache directory as the
[common cache directory](https://github.com/avajs/find-cache-dir),
`./node_modules/.cache/babel-loader`.

Previously, when `cacheDirectory` was set to `true`, babel-loader
tried to use the operating system's temporary directory as a cache
directory.

However, when running npm scripts as the root user,
[npm overrides the TMPDIR environment variable](npm/npm#4531).
This caused the cache files to be created in the project folder itself,
for example when using Docker: facebook/create-react-app#483.
fson added a commit to fson/babel-loader that referenced this issue Sep 18, 2016
Set the default cache directory as the
[common cache directory](https://github.com/avajs/find-cache-dir),
`./node_modules/.cache/babel-loader`.

Previously, when `cacheDirectory` was set to `true`, babel-loader
tried to use the operating system's temporary directory as a cache
directory.

However, when running npm scripts as the root user,
[npm overrides the TMPDIR environment variable](npm/npm#4531).
This caused the cache files to be created in the project folder itself,
for example when using Docker: facebook/create-react-app#483.
fson added a commit to fson/babel-loader that referenced this issue Sep 18, 2016
Set the default cache directory as the
[common cache directory](https://github.com/avajs/find-cache-dir),
`./node_modules/.cache/babel-loader`.

Previously, when `cacheDirectory` was set to `true`, babel-loader
tried to use the operating system's temporary directory as a cache
directory.

However, when running npm scripts as the root user,
[npm overrides the TMPDIR environment variable](npm/npm#4531).
This caused the cache files to be created in the project folder itself,
for example when using Docker: facebook/create-react-app#483.
@fson
Copy link
Contributor

fson commented Sep 18, 2016

I've sent a PR to babel-loader now.

@gaearon gaearon added this to the 0.4.2 milestone Sep 18, 2016
@gaearon
Copy link
Contributor

gaearon commented Sep 18, 2016

This should be fixed in 0.4.2.
Please verify!

@gaearon gaearon closed this as completed Sep 23, 2016
hzoo pushed a commit to babel/babel-loader that referenced this issue Oct 26, 2016
Set the default cache directory as the
[common cache directory](https://github.com/avajs/find-cache-dir),
`./node_modules/.cache/babel-loader`.

Previously, when `cacheDirectory` was set to `true`, babel-loader
tried to use the operating system's temporary directory as a cache
directory.

However, when running npm scripts as the root user,
[npm overrides the TMPDIR environment variable](npm/npm#4531).
This caused the cache files to be created in the project folder itself,
for example when using Docker: facebook/create-react-app#483.
Ognian pushed a commit to Ognian/babel-loader that referenced this issue Feb 27, 2017
Set the default cache directory as the
[common cache directory](https://github.com/avajs/find-cache-dir),
`./node_modules/.cache/babel-loader`.

Previously, when `cacheDirectory` was set to `true`, babel-loader
tried to use the operating system's temporary directory as a cache
directory.

However, when running npm scripts as the root user,
[npm overrides the TMPDIR environment variable](npm/npm#4531).
This caused the cache files to be created in the project folder itself,
for example when using Docker: facebook/create-react-app#483.
@lock lock bot locked and limited conversation to collaborators Jan 22, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

6 participants