-
-
Notifications
You must be signed in to change notification settings - Fork 0
Document progress on create-nuxt3-app
#3
Comments
Hm, does something like this work:
of course with slightly different paths. |
I also found a different solyution, checkout: https://v3.nuxtjs.org/guide/going-further/modules#provide-nuxt-plugins Code: import { defineNuxtModule, addPlugin, createResolver } from '@nuxt/kit'
export default defineNuxtModule<ModuleOptions>({
setup (options, nuxt) {
// Create resolver to resolve relative paths
const { resolve } = createResolver(import.meta.url)
addPlugin(resolve('./runtime/plugin'))
}
}) checkout how another option: import { resolve } from 'path'
resolve(runtimeDir, 'plugin') |
I have been doing some experimentation into how this works. I ran into the following issue. It always takes the current package into account when creating the link. See:
One option would be to remove I checked the documentation for |
As we are nearing the first version of
create-nuxt3-app
, I decided to track my progress and any issues I have with the project in this issue.What we have so far:
In order to release a first version I created two seperate npm packages. The first is the
cn3a-plop-files
package, which contains our templating files instructions on how to build the project. The second package is calledcreate-nuxt3-app
which is our main package. This package acts as a wrapper around the plop files.My main reasons for doing this was:
plop
package and run the cli through itThis separation leads me into the next segment, the outstanding issue I am facing:
Issues
index.ts
file of thecreate-nuxt3-app
I need to reference the plopfile. In order to do this I need to import the location of the plopfile on the host computer. I found the following solution usingrequire.resolve
:The only issue with this is that it does not work in esm modules and only in commonjs.
create-nuxt3-app
needs to use esm, as the packagenode-plop
, which is integral to integrating the plop functionality needs to run in esm.My question would be: How can I get the file location of a specific javascript file inside a esm project. I found two solutions, but have not had any success with implementing them:
Maybe @BracketJohn, you have some experience or could give me some points on what is:
The second issue I run into has to do with the custom actions I have added to the plop system. Actions let you write custom code that can be executed and used inside of the templating files. I wanted to create a simple action that copied over files from one location to another. The reason for this is that the default
add
andaddmany
actions also parse the files for handlebar syntax to inject custom variables (which we will sometimes but not always need). This leads me to my problem. I created the following custom action:It takes a src directory and a destination directory and paste the files from the source to the destination. When I test the script inside the
cn3a-plop-files
package this works without any issues. However when I try and use the action using the wrapper package (create-nuxt3-app
), it says that the directory I attempt to copy is not missing:I apologize in advance for these two question. I have been working the entire day trying to find solutions, without any success. Maybe you can help unblock me! Thank you!
The text was updated successfully, but these errors were encountered: