Svelte3/sapper/rollup exclude file pattern from compilation - configuration

I am trying to setup a TDD environment for an app I am building using svelte + sapper.
I need to ignore some files during the compilation (which uses rollup by default)... the reason why I need to exclude them is that I want to have a scalable scaffolding for my application, just like this:
src
|___components
|
|___aComponent
|___aComponent.svelte
|___aComponent.test.js
(e2e tests and integration will probably follow a different structure in order to maintain the separation of concerns and not to bound route and component.
The issue I am having right now is that js files are by default added into the project because of course I may need to create helper classes etc.
I already added exclude: **/*.test.js, but it looks like it's not enough...
here's my configuration.

This came up in a google search for me and is probably old, but in your exclude you have:
{
exclude: ["node_modules/#babel/**", "**/*s.test.js"]
}
instead of:
{
exclude: ["node_modules/#babel/**", "**/*.test.js"]
}

Related

Add custom Jinja2 filters/tests to MkDocs

While writing a Jinja2 template for MkDocs, I need some processing that is not covered by the filters/tests available (specifically, I need date formatting, which is a recurring example for custom filters in Jinja2-related resources across the Web). How can I define my own filters/tests and use them from templates?
To clarify the question, I know how to register new filters/tests in a Jinja2 environment from Python. My issue is that, as a user of MkDocs, I do not configure Jinja2 myself. So what I’m looking for is a way to hook into the setup that MkDocs performs.
I assume it is possible to add filters from a plugin. In fact, I have found one such plugin (undocumented and apparently not under active development, unfortunately). However, I hope that there is a simpler, local solution; one that would not involve implementing a plugin, packaging it as a Python package and publishing it on PyPi.
A possible solution is to use mkdocs-simple-hooks that allows to implement the hooks without needing to create a plugin. For example in your case:
plugins:
- mkdocs-simple-hooks:
hooks:
on_env: "docs.hooks:on_env"
docs/hooks.py
def on_env(env, config, files, **kwargs):
env.filters['my_filter'] = my_filter
env.tests['my_test'] = my_test
return env

How can I ignore unused partials in handlebars precompilation?

I would like to collect only the depending partials of a single template. Or otherwise ignore unused partials. Because it is a large project with lots of templates/partials and dependencies it is not possible to do that by hand.
Example file and folder structure would be something like:
/sites/foo.hbs - includes {> partial1}
/sites/bar.hbs - includes {> partial2}
/partials/partial1.hbs
/partials/partial2.hbs
Now I would like to precompile foo.hbs only. For precompilation i have to configure foo.hbs as root and /partials/*.hbs as partials.
The precompilation should end up with the content of foo.hbs and partial1.hbs in a single file.
Is that possible with handlebars at all? Maybe with an existing gulp plugin?
Your question contains a (somewhat) logical error.
Partials were initially intended to act as separate templates.
I guess your intentions are basically more syntactic sugar'ish,
- as you wish to write your code separately though merge it on deployment (some people call that OCD, since it has no real benefit in terms of performance).
Anyhow.
You can run a node scripts that runs through your HBS's, locates partials, extracts them into their parent elements and outputs these final templates.
Take a look at this following answer -
find files by extension, *.html under a folder in nodejs

PhpStorm - extend PHP Class template

I'm trying PhpStorm. I like the File Templates functionality and I'd like to use it in some more specific cases.
I'd like to extend to PHP Class template to create a new template that I'll be using for a specific type of classes. If I just duplicate the template, it doesn't really work as I'd expect. For example, while when I use PHP Class, the namespace is already compiled, this does not happen with my new template.
Is it possible to create another template so that it works as PHP Class?
Moreover... is there a way to order the templates in the editor, so I could have my new template near all the other PHP templates?
Is it possible to create another template so that it works as PHP Class?
Unfortunately not; at least not in current versions (2016.2).
When you are using New | PHP Class you see special dialog box that works with 3 templates (depends on what you will be creating: Class, Interface or Trait). This dialog uses file templates with predefined (default) names only and you can customize them as you wish .. but all other file templates for .php files will be just ordinary File Templates without those extras.
Based on your requirements you might be interested in https://youtrack.jetbrains.com/issue/WI-21711 ticket -- watch it (star/vote/comment) to get notified on any progress.
Please note that file templates could be project-specific (different template content for each project) -- this might be enough in some (rather simple) cases.
Moreover... is there a way to order the templates in the editor, so I could have my new template near all the other PHP templates?
Unfortunately not -- no sorting/subfolders is available (although you may have project-specific file templates).
Right now I may only suggest to use some common prefix in template name and build your sorting order around this idea.
Other than that -- https://youtrack.jetbrains.com/issue/IDEA-75239 + https://youtrack.jetbrains.com/issue/IDEABKL-3599 -- watch these tickets (star/vote/comment) to get notified on any progress.

yii2: where do my project's own html, css, js, and php-include files go?

Choices:
create an asset bundle (nicely explained by Ivo Renkema at How do I manage assets in Yii2?). this is what I need if I want to package my code for other use. alas, should I also do this for my own php include library functions? Or should I still stick them into the same php location as my other php files? In any case, if I want to go this route, presumably I would then customize the AppAsset class, included in the template, as explained in http://www.yiiframework.com/doc-2.0/guide-structure-assets.html .
stick my files directly into $basePath/web, where $basePath is typically something like /var/www/myapp/ (i.e., as $basePath/html/mine.html [and refer to it simply as href='/html/mine.html'], $basePath/css/mine.css , $basePath/js/mine.js, and $basePath/php/mine.php [and refer to it as $basePath= \Yii::getAlias('#webroot'); require_once('$basepath/php/mine.php') ])?
stick my local files where my php view code sits. the advantage is that the files are close to where I will use them. the disadvantage is that I may litter the view directories not only with php files, but also with my non-asset assets, even though they will be used only by these (my) php files.
it's a beginner's question for the google cache reference. it's about best practice when getting started. I can guess the answer, but we wouldn't want a novice to disseminate bad info.
If you need your CSS and JS files only in one view or one Controller you have 2 choices:
1- Create a asset bundle Here other guide if you need it.
2- Use registerJsFile() from View Class
You can acces from controller using:
Yii::$app->view->registerJsFile('js.path');
(Same with CSS files but using registerCssFile())
With the PHPfiles I always try to convert the code to yii's MVC. If you have a entire library try to add it as a component. Here a usefull guide

Sails.js asset management and referencing

Sorry for the noob question but I'm trying to start up a new application with Sails and include my assets. I'm using Bower to manage my packages for things like Bootstrap and JQuery. I had a read of this question and added a .bowerrc file which is now installing my Bower components to /assets.
I'm now confused as to how I should proceed to add these files into my project. It seems as though I can't just do a <script> tag in the header as I'm used to because it's giving me a file not found. Reading through the sails documentation it seems like Grunt should be creating a .tmp/public/assets folder in my project, but whenever I run sails lift and go to .tmp/ there is nothing in there.
I also read in the documentation that I should be using some kind of asset injection, I tried adding this to my HTML and it seems like it doesn't do anything.
My other question is around how I go about referencing images in my HTML. Obviously I can't just do something like src='assets/images/image.png, how should I go about this? Is there something really obvious that I'm missing?
Sails use grunt tasks to do lot of things during lift and build. You can get much better look how everything work if you take some time and check what is inside Gruntfile.js from root of your sails project.
About your specific question here is some information:
- from sails docs: "In order to take advantage of asset injection, minification, and concatenation you must put your assets in folder under assets/linker". This exactly mean that everything what you will put inside assets/linker directory will be affected by grunt tasks during lift. It mean that all files/directories from linker will be copy to .tmp/public and also some of that files will be processed before saved to .tmp/public.
- About adding tags. If you take a look at Gruntfile.js you will find this variables: var cssFilesToInject = [...] and var jsFilesToInject = [...] which contain files that will be automatic added to layout header during sails lift.
- About your 'other question', yes you can do something like 'src='linker/images/image.png' if you move that files to linker directory (assets/linker).
I hope this help :).