Nuxt.js: Allow configuring a destination path for build output

Created on 21 Feb 2017  路  15Comments  路  Source: nuxt/nuxt.js

I'd like to use Nuxt to compile client-side assets, with Phoenix as the server. By default, Phoenix expects source files in web/static, and the results of building those assets in priv/web/static. I can set srcDir to tell Nuxt to find its directory structure in web/static, which is great, but I see no way to tell it to place all build outputs in priv/web/static. Am I missing it?

Thanks.

This feature request is available on Nuxt.js community (#c248)
enhancement

Most helpful comment

@ndarilek Came across this issue and thought I'd let you know that you can change the dist folder (for the output of generated static files) by modifying the options.generate.dir programmatically or via the nuxt.config.js file:

generate: {
    dir: 'my-dir-other-than-dist'
  },

All 15 comments

@ndarilek are you talking about the outputs of nuxt build?

Futhermore, with nuxt, the ouputs are stores in a memory filesystem so you need to use nuxt as a middleware. I don't know if it's possible with Phoenix.

Yeah, sorry, nuxt build. It will likely be more relevant when
client-only apps are supported.

How do you develop your app with nuxt? Do you have nuxt.js server + phoenix server?

I want to know exactly how you want to use nuxt.js so I can see if a solution is possible.

Phoenix's own server serves up static content from priv/web/static,
compiling it from web/static. Currently a Webpack watcher runs in the
background, recompiling but not serving the assets as they change.

So basically nuxt build in a permanent loop, maybe with a -w switch
to remain active and keep rebuilding files on change, and the Phoenix
web server serving up HTML with the

and linking to the
output bundle.

Here
is a recipe that builds up a Webpack configuration integrating React
with Phoenix. Hopefully it clarifies what I'm currently doing, except
I've swapped out Vue and would like to just replace it all with Nuxt.

Thanks.

Hi,
I've red this great article but it's not very clear in my mind on why do you use it with Nuxt?
Because it's almost the same to do npm run dev with nuxt as launch phoenix server in development, isn't?

Sure, but isn't that the entire point of Nuxt, that all of this
configuration plus router/store setup isn't needed, because it can be
inferred from the filesystem layout and a few simple configuration tweaks?

This isn't much above and beyond adding support for client-side-only
bundles, it's just ensuring that the destination bundle can be written
to a configurable directory just as the source can be. At least, it
seems simple enough, perhaps I'm wrong.

Thanks.

Hi @ndarilek

Can your priv/web/static can be a symbolic link to the .nuxt/dist/ folder of the nuxt build ?

Maybe, but can you please help me to understand why there's resistance
to being able to set the output directory? We already can set the source
directory in the configuration. This feature just adds symmetry to the
configuration.

To put it another way, I could symlink the directories Nuxt expects to
find sources in into the source location, but I don't have to because
there is a configuration option that lets me tell the build tool to
check a different directory. I don't know why there shouldn't be a
corresponding option to control where bundles are written.

If it's just a matter of having the time to do it, I can be patient, or
look into implementing it myself and submitting a PR.

:+1: Can be useful

It's planned for the 0.11 馃憤

it's now possible with buildDir property.

I think what I actually want is to set a distDir. I.e. build artifacts go into .nuxt/, distribution files into ../priv/static. Is that possible?

OK, never mind, I want generate and not build. The existence of both is a bit confusing.

Having established that, I suppose there isn't much use for buildDir after all. Apologies for the confusion.

@ndarilek Came across this issue and thought I'd let you know that you can change the dist folder (for the output of generated static files) by modifying the options.generate.dir programmatically or via the nuxt.config.js file:

generate: {
    dir: 'my-dir-other-than-dist'
  },

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

vadimsg picture vadimsg  路  3Comments

bimohxh picture bimohxh  路  3Comments

jaredreich picture jaredreich  路  3Comments

bimohxh picture bimohxh  路  3Comments

mattdharmon picture mattdharmon  路  3Comments