Set pug includes to not compile - directory

I am running the pug CLI with
pug src --out web --watch
If I have
src/
index.pug
includes/
scripts.pug
web/
index.html (generated)
And in index.pug: include includes/scripts.pug
With this setup if I modify the scripts.pug, it generates web/includes/scripts.html that I don't need and I don't want in order to keep things clean.
Is there a way to avoit certain files / directories to compile?
(for now a workaround is having the includes in html form but maybe there's a way)

Adding an underscore prefix to files should tell Pug to not compile them directly. This is super helpful for files that are only used as includes.
So you should rename scripts.pug to _scripts.pug:
src/
index.pug
includes/
_scripts.pug
web/
index.html (generated)
And then rewrite your include statement in index.pug to be: include includes/_scripts.pug

The pug-cli doesn't know about not compiling certain files. Like the previous answer mentions, it does work with gulp-pug but not pug-cli. The only way I can think of not to compile includes or extends files is to put those files in a separate root directory. For example:
src/
templates/
views/
index.pug
includes/
scripts.pug
web/
index.html (generated)
Then set pug to compile the views directory only.
pug -w src/templates/views/ -o web/ -P

Related

What to use in Gulp to make a path into node_modules

I have a project that uses gulp and I need to use splide js to create a slider, i used NPM to install splidejs and now I need to include splidejs CSS file to my main.scss however whatevere I do to get to node_modules file from my main.scss is not working. In webpack we use ~to get to node_modules but how can i do it in gulp to get there?
I have tried with ~ and with node_modules path and directory in project but nothing works
In Gulp, you can use the gulp.src() function to specify a file path that includes the node_modules directory. This function allows you to specify the source files that you want to include in your Gulp task.
For example, if you want to include all the JavaScript files in the node_modules directory in a Gulp task, you could use the following code:
gulp.src('node_modules/**/*.js')
.pipe(someGulpPlugin())
.pipe(gulp.dest('dist'));
This will include all the JavaScript files in the node_modules directory and its subdirectories in the Gulp task. The ** wildcard indicates that all subdirectories should be included, and the *.js pattern indicates that only JavaScript files should be included.
You can also use other file globs or patterns to specify the specific files that you want to include in your Gulp task. For more information on using file globs with Gulp, you can refer to the Gulp documentation.

How to exclude a folder from rsync

I am using rsync to deploy a git branch with my production server. Currently, I got js files stored in two locations:
assets/js/
js/
When I run rsync using --exclude js, non of the both folders will be sync, while I want the assets/js/ folder to be synced and the js/ folder inside my root folder to be skipped. How can I achieve this?
You need to specify the pattern for those files and directories:
using:
CWRULE [PATTERN_OR_FILENAME]
CWRULE,MODIFIERS [PATTERN_OR_FILENAME]
so you would have something like
CW- js/
For even more detailed info you can see the man page at the section
Include/Exclude Pattern Rules
from this link, hope it helps

index.html stored in css/ directory

I am building a site that has a page titled 'CSS'. So, to me, the most logical place to store the page's index.html file is in the corresponding css/ folder.
Are there any potential problems I could run into using the css/ directory as a subpage folder as well as the place I store my css/sass like i the following directory:
siteroot
css/
index.html (sub-page I am asking about)
mainstyle.css
sass/
index.html
js/
app.js
img/
example.png
It's worth pointing out I'm not using relative URLs, so I can't see file paths being an issue.

How to change the path before injection

Is it possible to change the path of the injected file before injection occurs?
I am using Grunt/Bower/Connect/Wiredep, and my directory structure is:
www
|- dev-dist/
|- node_modules/
|- src/
|- vendor/
|- bower.json
|- Gruntfile.js
|- package.json
(Note: in my .bowerrc file I've added directory: vendor)
When I run the custom task grunt serve:dev it will create the directory dev-dist, I will then copy my index.html (only) to the folder, after which I run the task wiredep.
After running wiredep, the src paths to my dependencies are all prefixed with '../vendor/'. The problem is that when I run connect I have the option base: ['vendor', 'dev-dist', 'src']. When everything is served, the relative path to vendor doesn't make any sense because the vendor dir is already served at the root.
Is there a way I can modify the path to the injected files before wiredep injects them? (So I can remove the '../vendor')
What I would like to have happen is from the same workspace be able to run grunt serve:* and specify dev/stage/prod environments. This is why I did not want to serve the whole www directory.
Is there a way to exclude folders from being served in connect? (So instead of specifying base:[...], I can just exclude the stage-dist / prod-dist folders)
Thanks,
JD
You can use the option ignorePath with a regular expression
ignorePath: /\.\.\//,
from the wiredep to remove the ../ from the path that is getting injected. The configuration details are available over here https://github.com/taptapship/wiredep#configuration
I haven't used connect yet, so I am not sure of your second part of the question.

Why does Symfony create a separate vendor folder in my root?

when I install Symfony according to the guide (option 1 with composer) it creates the folder structure as expected (and mentioned in that guide):
path/to/webroot/
Symfony/
app/
src/
vendor/
web/
But in the root folder it also creates an empty vendor/ folder. In this vendor folder there is a subfolder named composer/.
path/to/webroot/
Symfony/
vendor/
composer/
Both directories are empty (no hidden files). So two questions:
Is this a required folder or is it kind of a bug that these folders are installed? Or may this be a directory for composer-specific files?
Can I delete this folder without any danger?
That empty folder is generated when you don't pass the target-directory parameter to composer:
php composer.phar create-project vendor/project target-directory [version]

Resources