Implementing a directory structure in Grunt - coffeescript

I am working on a project using coffeescript and want to have a directory structure like:
project/
Gruntfile
common/
*.coffee
*.spec.coffee
*.scaffold.coffee
bin/
test/
server/
*.coffee
*.spec.coffee
*.scaffold.coffee
bin/
test/
client/
*.html
*.css
*.coffee
*.spec.coffee
*.scaffold.coffee
bin/
test/
Where coffee files get compiled to bin, spec.coffee and scaffold.coffee get compiled to test. There are directories containing static files that are not shown.
Is there an easy/standard way to do this?

this is a general question so the general answer is: yes, most grunt plugins have easy ways to configure each task, identify source files and where the output gets generated.
take a look at the documentation for grunt-contrib-coffee, shows lots of examples of how to config directories to process coffee files including options to flatten sub-directories, etc.
https://github.com/gruntjs/grunt-contrib-coffee

Related

How to specify the main class (in the root directory) for Mill to run?

I am new to the sbt and mill, and I am practicing to use both tool to build the chisel (scala project). View this github repo as a reference, I am wondering to know how to write the mill-version build.sh in that repo.
Here is my directory structure
─ chisel-template (root directory / projects directory)
├── build.sc
├── build.sh
├── src
| └─main
| └─scala
| └─lab1
| └─Mux2.scala
└── _temphelper.scala
What the build.sh do is preparing a boilerplate as main function in the root directory to make compile and run process much easier, and it's sbt version. I'm curious that why sbt can detect the main function (_temphelper.Elaborate) even it's not in the src/main directory. And when I change to use Mill, Mill can't detect the _temphelper.scala at all, unless I move the file to root/src/main. Is there settings that can make Mill do what sbt can do?
I'm not sure whether this issue is related to...
altering the sourceDirectories in sbt and chiselMoudule.sources in Mill. Any advice is welcome.
modify the millSourcePath to realize my request.
My quetions is What setting should I do to make mill can detect the main class that be in the root directory?
This is because sbt is including any Scala files it finds in the project root directory as sources files, unless told otherwise.
In contrast, Mill will only use the source files found under whatever directories are specified with sources. As a consequence, you may want to add the project root directory as source directory, but I strongly advice to do not so.
Best is to move the _temphelper.scala file either to one of the source directories or create a new dedicated directory, move the file there and add this directory to the sources like this:
object chiselModule extends CrossSbtModule // ...
{
def sources = T.sources {
super.sources() ++ Seq(PathRef(T.workspace / "your" / "new" / "directory"))
}
}

BabelJS: Doesn't find all .js files in directory

Babel doesn't find all of my .js/.es6 files in my directory.
I have this directory structure:
src/
assets/
sample/
models.es6
scripts/
playground.es6
If I run babel src --out-dir dist --source-maps --copy-files --presets env, it only transpiles /src/assets/sample/models.es6 and doesnt go through src/scripts/playground.es6.
What am I doing wrong?
Looking forward to your response!
You can do like below :
babel src/** --out-dir lib
more at official doc
Compile Directories
Compile the entire src directory and output it to the lib directory. You may use --out-dir or -d. This doesn’t overwrite any other files or directories in lib.
if you still stuck, you can use gulp or grunt or webpack to load/transpile mupltiple directives from different locations.
Hope it helps
I found the problem. It has barely to do with Babel.
Inside the src/assets/** is my Realm database sample.realm (https://realm.io). The file itself doesnt cause the problem. But if you open the sample.realm file with Realm Studio on MacOSX, a file called sample.realm.note gets created. This file causes babel to not exit the transpile task.

Can I have multiple configure.ac files and what to do with AC_OUTPUT then?

I have this directory structure:
foo
foo/libfoo - libfoo project
foo/libfoo/src - sources
foo/foo - foo project
foo/foo/src - sources
There are two separate things that have to be build here, a libtool library (libfoo) and an executable (foo) using that library.
I could just place a configure.ac file into each foo/libfoo and foo/foo and everything would be fine.
However I would like to be able to build both projects at once, so I thought about placing an additional configure.ac into the top level foo directory.
Is this a good idea?
If yes, how would the AC_OUTPUT makro be used in such a case?
Does the top level configure.ac file generate all the Makefiles in the whole tree or are there separate AC_OUTPUT makros in the sub directories that each output there Makefiles?
Since both projects have different dependencies I would think the subdir ac files do the output of their makefiles?
Can the two projects in the sub dirs still be build separately in this case?
There is a AC_CONFIG_SUBDIRS macro that does what I want, it recurses into subdirs and executes the configure.ac files there.
The sub dir projects can still be build independently.
My Makefile.am only contains SUBDIRS = libfoo foo now.
The configure.ac file contains AC_CONFIG_SUBDIRS=([libfoo foo]).

Babel multiple directores into single output directory

I've scouered the documentation for Babel and cannot seem to find an answer, so I turn to the glorious community.
With a directory structure like this:
src/
folder1/
file1.js
file2.js
folder2/
file3.js
folder3/
file4.js
file5.js
I want Babel to transpile all files into a flattened directory:
lib/
file1.js
file2.js
file3.js
file4.js
file5.js
No matter what I try, Babel always inherits the src/ directory structure. Any ideas?
If you are using babel-cli, you can do this:
babel folder1 folder2 folder3 folder4 -d lib
which works fine if you have a limited number of folders. It'll output them all flattened.
To expand on samanime's answer, if you're using babel-cli, you can simply use a wildcard on your parent folder...
babel src/** -d lib

Copy sources files into target directory with SBT

I recently decided to use SBT to build an existing project.
In this project I have some .glsl files within the scala packages which I need to copy during the compilation phase.
The project is structured like this :
- myapp.opengl
- Shader.scala
- myapp.opengl.shaders
- vertex_shader.glsl
- fragment_shader.glsl
Is this file structure correct for SBT or do I need to put the .glsl files into an other directory. And do you know a clean way to copy these files into the target folder ?
I would prefer not putting these files into the resources directory since they are (non-compiled) sources files
Thanks
I would not recommend putting those files into src/main/scala as they do not belong there. If you want to keep them separate from your resource files, you can put them in a custom path, e.g. src/main/glsl and add the following lines to your project definition to have them copied into output directory:
val shaderSourcePath = "src"/"main"/"glsl"
// use shaderSourcePath as root path, so directory structure is
// correctly preserved (relative to the source path)
def shaderSources = (shaderSourcePath ##) ** "*.glsl"
override def mainResources = super.mainResources +++ shaderSources