We want to use the same build system across multiple projects. I have a working brunch configuration file that I want to put in a git submodule, so that that submodule can be referenced in multiple projects and changes are easily propagated (less fragile than copy and paste and sets authoritative source of brunch-config.js).
Putting brunch-config.js in a git submodule though causes my folder structure to end up like this:
WebApp // git root
|---Brunch-Build-System // git submodule
| |---brunch-config.js
|---node_modules
|---source // all the source code I want compiled
Brunch operates assuming brunch-config.js would be at the same or higher level than the source being compiled. In this setup, this is not the case. I've tried modifying my brunch-config.js to use a relative path to no avail. Here is my files
block of the Brunch configuration as it currently stands, without any relative path attempt:
files: {
javascripts: {
joinTo: {
'js/lib.js': /^(?!source\/)/
},
entryPoints: {
'source/scripts/app.jsx': {
'js/app.js': /^source\//
},
}
},
stylesheets: {joinTo: 'css/core.css'}
}
How could I modify this to use a relative path given the desired folder structure above? Is this even possible?
A submodule needs to be associates with a root folder within the parent repo: it is the gitlink (a special entry in the main repo index ) which records which SHA1 that submodule is checked out.
In your case, it would be best if you can use, in a post-checkout hook , a script ensuring there is a symbolic link between:
brunch-config.js
at its correct place and Brunch-Build-System / brunch-config.js
from the submodule The lines to include in the hook would be something along the lines of
#!/bin/bash
if [ ! -e /correct/path/for/brunch-config.js ]; then
ln -s /correct/path/for/brunch-config.js Brunch-Build-System/brunch-config.js
fi
Although the OP being on Windows:
I ended up just programmatically copying the file over and gitignoreing the copied file
In general, brunch supports relative paths. But in order to make it work, you have to first make sure that the other folders are watched
. See this part in the docs . For your case, add this to your config.
paths = {
watched: ['../source', '../node_modules'],
}
Then prepend the RegExs by ..\\/
.
joinTo: {
'js/lib.js': /^..\/(?!source\/)/
},
entryPoints: {
'source/scripts/app.jsx': {
'js/app.js': /^..\/source\//
},
}
Instead of a RegEx, you can also write a function that takes the path as an argument and has to return whether the path should be included or not. See this part in the docs .
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.