How does webpack determine which files/folders it will include in a bundle - scalajs-bundler

I have a set of files in my project's src/main/resources folder - such as index.html, myproject.css, i18n.js
When I run webpack only one file is automatically copied over to the bundle, namely 118n.js. Why does this get bundled but nothing else?

Currently, all the .js files on the classpath are eligible to be bundled. This is why your i18n.js file is included in the resulting bundle.
Note, however, that it is not planned to continue to support this behavior (relying on .js files on the classpath). Instead, you should include which resources are eligible to be bundled with the jsSourceDirectories setting key. For instance, to include all the files of the src/main/resources directory:
jsSourceDirectories += (Compile / resourceDirectory).value

Related

How to force npm publish to include files (that are not required by the entry)?

I have an npm project for generating packages. It contains a folder called templates. The files in templates are not required by the entry point index.js instead they are collected using fs. They are not appearing in the published version. I have tried adding files: ["templates"] to the package.json (and various combinations ("templates/*", "templates/**/*", "templates/something/somefile.js") but the files are never included. The only files in templates folder that appear are Licence and package.json.
How do I make npm include these files in the published version?
Edit: My project directory has a .gitignore file but that does not include the templates folder. It does not have an .npmignore file.
The reason that the License and package.json files are appearing in your templates folder, is because npm ignores any attempt to exclude these files.
I would check that you don’t have any .ignore files in your templates folder and also check further up the filesystem, does the folder that contains your project have one? What about it’s parent and so on?
Then try temporarily removing the .gitignore file as well.
Lastly try publishing from another machine if nothing else works.

quasar can't build asset folder

My project has static folder and asset folder.
I use quasar dev to build project and the building project is stored in dist folder. But in the dist folder, it only has static folder, it doesn't has asset folder.
How can I let asset be packaged in dist folder?
I also had some struggle working with these two directories in Quasar. So I was very happy when I found this page in the documentation. The difference between assets and statics is described as follows:
Assets vs Statics
Files in the “assets” folder are only included in your build if they have a
literal reference in one of your Vue files. Every file and folder from the > “statics” folder are copied into your production build as-is, no matter what.
So I guess that you currently do not use any of the files inside the assets directory in at least one of your components.
Example: One possible way to make logo.png be part of the dist folder is to use the asset in a Vue component like this (also taken from the docs): <img src="~assets/logo.png">. Afterwards run quasar build and check the output in your dist folder. Good luck!

should I add app.js file in gitignore for nodejs/vuejs app?

I am new to vuejs. Recently I noticed that when I pull, it says conflict in app.js file. But I can't find the issue as app.js file is big.
Sould I add this file to gitignore file?
what is best practice to work with vue js?
I imagine you are building to a folder /dist and the app.js being conflited is the one inside of it.
You should ignore the /dist altogether. This folder is generated on the building process, meaning everyone that runs the project will update and create it.
Here is the default vue-cli .gitignore:
.DS_Store
node_modules
/dist
# local env files
.env.local
.env.*.local
# Log files
npm-debug.log*
yarn-debug.log*
yarn-error.log*
# Editor directories and files
.idea
.vscode
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw*
Not that not anything here may be useful to put in your own .gitignore. But you should for sure have at least node_modules and /dist.
If you are building the Vue project by scratch then I can say the following, when building/compiling your Vue project, best practices say that you should handle your entire production ready project in a dist/ or build/ directory where your main app.js file where the conflicts you are having would occur. This directory is only reserved for deploying the app and is not saved into your code repository, hence on why you should add to the .gitignore file the directory that holds such production files.

Gulp less with images

Is there a way for gulp-less (or some other tool) to take the paths to images that are referenced in the .less/.css file and put the files to the destination folder?
Right now when I install a node module, I #import the css file from /node_modules/... directory to my main .less file and it will be included in the bundle, but the images that come with the module are still located under /node_modules/... folder which I don't plan to deploy so using a relative URL would be pointless.
You should consider using bower to split your dev dependencies (handled by npm, non-deployed stuff) and front-end libs (handled by bower, deployed stuff).
Using a .bowerrc like this, you can tell where to save the libs in you projects structure:
{
"directory": "./<your-public-folder>/libs"
}

How to put a component's classes dir in classpath

I am building groovy classes under my src/main/groovy dir and I build them and the .class files are under build/classes, but when I run the code it does not see those classes.
What do I have to do to make those files be seen?
If your src and build directories are in a component directory you can have the build file either put the classes in the /classes directory or put them in a jar file in the /lib directory. You can also put class files and other classpath resources in the runtime/classes directory or in a jar file in the runtime/lib directory.
The Moqui classloader adds these to the classpath automatically at runtime.