tailwindcss icon indicating copy to clipboard operation
tailwindcss copied to clipboard

ResolveConfig Issue

Open cizza opened this issue 7 years ago • 8 comments

Hi,

I've upgraded to a 1.12 tailwindcss version and I've encountered an issue with the resolveConfing.js function.

I'm using basically the same syntax as displayed on the website:

`import resolveConfig from 'tailwindcss/resolveConfig'; import tailwindConfig from '../../../tailwind.config.js';

export default resolveConfig(tailwindConfig)`

However when I compile the stylesheets, I get an error:

ERROR in ./node_modules/reduce-css-calc/dist/parser.js Module not found: Error: Can't resolve 'fs' in 'C:\xampp\htdocs\widow_source\node_modules\reduce-css-calc\dist'

I'm using laraveMix processing tailwind thusly:

`const mix = require('laravel-mix'); require('mix-tailwindcss'); require('laravel-mix-alias');

mix.js('resources/js/scripts.js', 'public/js') .sass('resources/sass/styles.scss', 'public/css') .tailwind() .version();`

Npm install of the missing 'fs' dependency doesn't solve the issue.

Any help would be welcome,

Thank you.

cizza avatar Sep 18 '19 10:09 cizza

This is an annoying problem and I hope this PR gets merged to fix the core of it, but in the mean time you need to stub the fs module in your webpack config:

https://webpack.js.org/configuration/node/#other-node-core-libraries

Setting fs to false or 'empty' will both work 👍🏻

adamwathan avatar Sep 18 '19 12:09 adamwathan

For Laravel Mix specifically, you'll want to update your config to this:

const mix = require('laravel-mix');
require('mix-tailwindcss');
require('laravel-mix-alias');

mix.js('resources/js/scripts.js', 'public/js')
.sass('resources/sass/styles.scss', 'public/css')
.tailwind()
.version()
.webpackConfig({
  node: { fs: false }
});

adamwathan avatar Sep 18 '19 12:09 adamwathan

Thank you!

cizza avatar Sep 18 '19 13:09 cizza

In my case I had to provide

.webpackConfig({ node: { fs: 'empty' } });

cizza avatar Sep 18 '19 13:09 cizza

I worked around the issue with externals:

externals: { fs: "commonjs fs" }

M3S8 avatar Sep 24 '19 20:09 M3S8

I worked around the issue with externals:

externals: { fs: "commonjs fs" }

in which file @m11m ?

bipsBro avatar Sep 25 '19 12:09 bipsBro

@bipsBro in your webpack config 👍

https://webpack.js.org/configuration/externals/

adamwathan avatar Sep 25 '19 13:09 adamwathan

Tried to add tailwind custom-forms to my config and got this error. On the latest version of Laravel+Tailwindcss

Not sure why none of the above solutions work in my case.

mehrancodes avatar Sep 28 '19 20:09 mehrancodes