phenomic icon indicating copy to clipboard operation
phenomic copied to clipboard

[plugin-public-assets] Can't find public folder

Open jcayzac opened this issue 7 years ago • 2 comments

My phenomic.config.js file has:

module.exports = {
  …
  plugins: [
    …
    ['@phenomic/plugin-public-assets', { path: __dirname + '/public' }],

The directory is present, but the public assets plugin can't find it:

blog [master *$ u= origin/master] yarn start
⚠ @phenomic/plugin-public-assets:  No '/Users/jcayzac/Desktop/Phenomic/blog/public'
folder found. Please create this folder if you want static files to be served from the root
(eg: favicon.ico).
…
blog [master *$ u= origin/master] ls /Users/jcayzac/Desktop/Phenomic/blog/public
favicon.ico  robots.txt

jcayzac avatar Jul 01 '18 02:07 jcayzac

It's probably because https://github.com/phenomic/phenomic/blob/master/packages/plugin-public-assets/src/index.js#L35 does path.join(config.path, options.path) and thus doesn't support absolute paths. Changing to { path: 'public' } fixed my problem.

Also worth mentioning that not specifying the path option resulted in the error below. Not sure why the react preset doesn't suffer from it.

✖ @phenomic/core:  The "path" argument must be of type string. Received type undefined
✖ @phenomic/core:  TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received type undefined
    at assertPath (path.js:39:11)
    at Object.join (path.js:1157:7)
    at Object.addDevServerMiddlewares (/Users/jcayzac/Desktop/Phenomic/blog/node_modules/@phenomic/plugin-public-assets/lib/index.js:50:52)

jcayzac avatar Jul 01 '18 02:07 jcayzac

Thanks for the feedbacks. Will try to improve that.

MoOx avatar Jul 27 '18 13:07 MoOx