How do I set the target path in the copyfiles method with webpack in a Symfony project? - symfony

Following these instructions I have been able to copy files from their location and into the relative output directory.
.setOutputPath('public/assets/#BUILDNUMBER#')
.copyFiles({
from: './assets/images/favicon',
})
The docs go on to explain there is an optional "to" target path which I want to be "/images/favicon" (so the whole output path would be public/assets/#BUILDNUMBER#/images/favicon) but the way I'd expect to write this out creates errors when I run webpack.
.setOutputPath('public/assets/#BUILDNUMBER#')
.copyFiles({
from: './assets/images/favicon',
to: 'images/favicon'
})
Conflict: Multiple assets emit different content to the same filename images/favicon. Original source assets/images/favicon/ms-icon-150x150.png
I'll note that currently the auto-generated #BUILDNUMBER# directory has an images subdirectory but not a favicons subdirectory, I have also tried pointing to the already existing images directory instead but it produces this error:
Error: EISDIR: illegal operation on a directory, open '/opt/my-site/public/assets/#BUILDNUMBER#/images'
So how can I set my copyFiles "to" path to point to public/assets/#BUILDNUMBER#/images or public/assets/#BUILDNUMBER#/images/favicon?

I think you're missing the placeholders in the "to" parameter.
See the error message:
Conflict: Multiple assets emit different content to the same filename images/favicon
Webpack thinks "images/favicon" is the filename.
Maybe try this:
.copyFiles({
from: './assets/images/favicon',
to: 'images/favicon/[path][name].[ext]'
})
Here's a list of supported placeholders: https://github.com/webpack-contrib/file-loader#placeholders
If you're using versioning (.enableVersioning()) e.g. you have to add the hash as well:
.copyFiles({
from: './assets/images/favicon',
to: 'images/favicon/[path][name].[hash:8].[ext]'
})

Related

File Should Exist is not recognizing filepath

I'm using the File Should Exist keyword to check for an existing file in a List.
This is the high-level format:
Variables:
#{Files} /Desktop/Other/scooby.txt
... /Desktop/DummyFiles/daffy.txt
... %{CURDIR}/mickey.txt
Test Case:
Given File Should Exist ${Files[0]}
[...]
Output:
Setup failed:
Path '/Desktop/Other/scooby.txt' does not exist.
I'm not sure why this happens. The file name and filepath are correct. I also tried a bunch of different combinations (I copied the file over to the subdirectory this script is running from but that also doesn't work). I tried making the filepath a scalar variable instead of a List/array. Adding ".." in front of the file path doesn't work either. I've looked into "Glob pattern" but I don't think that's the issue either.
Always use absolute paths if in doubt. For example - /Desktop/Other/scooby.txt Does not point to any "meaningful" path even on windows because its lacking the the drive. On windows, using C:/Users/$yourlocalusername/Desktop/Other/scooby.txt might be working (replace $yourlocalusername with correct value)
Relying on relative paths (like in your example, 2 first ones are relative even thought you start with /, because in windows you still have a drive at the start) - you will need to ensure that working directory is set to a specific directory before you run your suite. Now, if you run your suite via IDE, current working directory might not be what you expect it to be so before you are familiar with how relative & absolute paths work - prefer to use absolute paths. See https://www.computerhope.com/issues/ch001708.htm - maybe that will clear out your issue.
You can either use ${CURDIR} or do not start the relative path with '/'.
I guess when starting with '/' , RF does not take this as relative path input and try to map the address from root directory i.e. C:
In below example, I have demonstrated both the approach, and it works fine for me.
*** Settings ***
Library OperatingSystem
Documentation Demonstrating File Exist keywords
*** Variables ***
#{Files} Data/VariableData/ConditionalFlows.robot
... Data/VariableData/testdata.robot
#{Files2} ${CURDIR}/Data/VariableData/ConditionalFlows.robot
... ${CURDIR}/Data/VariableData/testdata.robot
*** Test Cases ***
TS002-Check For File Existence
[Documentation] File exists
${File} File Should Exist ${Files}[0]
${File} File Should Exist ${Files2}[0]

CMake-qt: Including Autogened file from sibling Project. How to do it right?

commonLib is a collection of Files used for some other Targets declared in sibling folders which are then added to the parent CMakeLists.txt via add_subdirectory(). commonLib contains foo.h and foo.ui (which is translated to ui_foo.h by AUTOUIC)
otherLib includes foo.h from commonLib.
It feels like I am missing something obvious.
Is it necessary to use something like target_link_libraries?
Can I add the autogen folder of commonLib to the include folders of otherLib? (with target_include_directories(commonLib PRIVATE ${AUTOGEN_FOLDER_OF_otherLib}) )
How do I make sure commonLib is autogen-ed before otherLib?
Please let me know if there is information missing for understanding the problem.
I am using cmake-converter to convert existing .sln files to CMakeLists.txt.
I assumed finding success with using target properties like:
* AUTOGEN_TARGET_DEPENDS
* AUTOGEN_BUILD_DIR
but I failed.
commonLib contains following code:
find_package(Qt5 REQUIRED COMPONENTS Widgets)
set_target_properties(${PROJECT_NAME} PROPERTIES
AUTOUIC ON
)
otherLib contains following code:
add_dependencies(${PROJECT_NAME}
commonLib
)
I expected CMake to successfully generate the ui_foo.h from commonLib (which it actually does in the folder commonLib_autogen/include_) and then use ui_foo.h for compilation with otherLib.
Resulting Errormessage is:
d:\path\to\otherLib\../otherLib/foo.h(6): fatal error C1083: Cannot open include file: 'ui_foo.h': No such file or directory [D:\build_dir_of\otherLib\otherLib.vcxproj]
The Problem was the use of
# include "ui_foo.h"
in the header (foo.h). Moving the include to the foo.cpp file and forward declaring the Ui::FooBar like this:
namespace Ui { class FooBar; }
resolved it.

Change output directory in "sbt-native-packager"

Sorry, I'm new to sbt and the "sbt-native-packager". What I need to do is to map whole directories to the .zip file and change the output path.
This how I've done my mapping of the directory:
mappings in Universal <++= (packageBin in Compile, baseDirectory ) map { (_, baseDirectory) =>
val dir = baseDirectory / "migrations"
(dir.***) pair relativeTo(dir.getParentFile)
}
The mapping works perfectly fine, but I need to have a specific folder structure in the resulting .zip file.
In this example this directory is mapped to ".../target/stage/universal/migrations" but I need it to be mapped into a folder "db" like this: ".../target/stage/db/universal/migrations"
Many thanks in advance!
For mapping complete directories there are some MappingHelpers you can use. Your code can be simplified to
mappings in Universal ++= directory(baseDirectory.value / "migrations")
Regarding your second question, how to change the output folder. The question is not quite correct, as it should be: "how to change the destination path of a mapping". The universal packaging is a bit special as the target ouput looks like the resulting package.
Native packager uses mappings (sequence of File -> String tuples) that define a file and the corresponding output path in the resulting package. So if you want to change
# current
./target/stage/universal/migrations
# expected
./target/stage/db/universal/migrations
I assume you want the migrations in your zip file in a db folder like this
/ # zip root
bin/ # start scripts
db/ # migrations go here
conf/ # configuration files
lib/ # jars
In order to accomplish this you have to change the destination string. This would look something like this ( not tested ):
mappings in Universal ++= contentOf(baseDirectory.value / "migrations").map {
case (file, dest) => file -> s"db/$dest"
}
cheers,
Muki

How to detect root files in LESS using gulp compilation

Here is the thing. I have following structure of my LESS files:
/less/root.less
/less/includes1/*.less (a lot of less files)
/less/includes2/*.less (a lot of less files)
I am using gulp to compile my LESS files. Source:
gulp.task('less', function () {
var combined = combiner.obj([
gulp.src('./less/**/*.less'),
less(),
gulp.dest('./www/dist/screen.css')
]);
// any errors in the above streams will get caught by this listener, instead of being thrown:
combined.on('error', console.error.bind(console));
return combined;
});
The problem is in the specified path. I understand this path ./less/**/*.less like this: Recursively go through all folders and compile all files that ends .less. Problem is that compiler wants to compile each file one by one and doesnt know that all files are included to my source.less. It doesnt look for root files and doesnt know what files are included parts and what are root files.
How do I tell LESS parser which files are root and which files are to be imported. In SASS it is specified via underscore in file name like this: _includedPart.scss.
Well you can use https://github.com/robrich/gulp-ignore. See: How can I use a glob to ignore files that start with an underscore?
var condition = '_*.less'; //exclude condition
gulp.src('content/**/*.less')
.pipe(gulpIgnore.exclude(condition))
In many situations you all your Less code into a single CSS file. Your main file(s) contain #import directive which point all other required Less files.

Compile LESS files with source maps

How can I compile a LESS file to output a source map file (.css.map) in addition to a CSS file? Is there a way to do it on both command line (NodeJS's lessc) and on any GUI-based programs?
Update: New shortest answer
The docs have been updated! As new features hit LESS, sometimes the docs lag behind a bit, so if you're looking for bleeding-edge features, you're still probably better off running lessc (see longer answer) and checking what pops out of the help text.
http://lesscss.org/usage/
Short answer
You're looking for any number of the following options from the command line:
--source-map[=FILENAME] Outputs a v3 sourcemap to the filename (or output filename.map)
--source-map-rootpath=X adds this path onto the sourcemap filename and less file paths
--source-map-basepath=X Sets sourcemap base path, defaults to current working directory.
--source-map-less-inline puts the less files into the map instead of referencing them
--source-map-map-inline puts the map (and any less files) into the output css file
--source-map-url=URL the complete url and filename put in the less file
As I write this I'm not aware of any GUI options that generate maps (source maps were only added to LESS in the last few months) -- sorry to not have any better news. I'm sure they'll add support in as they update over the next year.
Longer answer
If you run lessc from the command line without any parameters it will give you all the options. (In my experience, this is more up to date than their documentation, so it'll at least get you pointed in the right direction.) with all the most recent map stuff included.
The easiest combo to use for dev is --source-map-less-inline --source-map-map-inline as that will give you your source maps embedded in your output css.
If you'd like to add a separate map file, you can use --source-map which, from my.less will output my.css and my.css.map
For reference: when I run my copy (v 1.6.1 at the moment) I get
usage: lessc [option option=parameter ...] <source> [destination]
If source is set to `-' (dash or hyphen-minus), input is read from stdin.
options:
-h, --help Print help (this message) and exit.
--include-path=PATHS Set include paths. Separated by `:'. Use `;' on Windows.
-M, --depends Output a makefile import dependency list to stdout
--no-color Disable colorized output.
--no-ie-compat Disable IE compatibility checks.
--no-js Disable JavaScript in less files
-l, --lint Syntax check only (lint).
-s, --silent Suppress output of error messages.
--strict-imports Force evaluation of imports.
--insecure Allow imports from insecure https hosts.
-v, --version Print version number and exit.
-x, --compress Compress output by removing some whitespaces.
--clean-css Compress output using clean-css
--clean-option=opt:val Pass an option to clean css, using CLI arguments from
https://github.com/GoalSmashers/clean-css e.g.
--clean-option=--selectors-merge-mode:ie8
and to switch on advanced use --clean-option=--advanced
--source-map[=FILENAME] Outputs a v3 sourcemap to the filename (or output filename.map)
--source-map-rootpath=X adds this path onto the sourcemap filename and less file paths
--source-map-basepath=X Sets sourcemap base path, defaults to current working directory.
--source-map-less-inline puts the less files into the map instead of referencing them
--source-map-map-inline puts the map (and any less files) into the output css file
--source-map-url=URL the complete url and filename put in the less file
-rp, --rootpath=URL Set rootpath for url rewriting in relative imports and urls.
Works with or without the relative-urls option.
-ru, --relative-urls re-write relative urls to the base less file.
-sm=on|off Turn on or off strict math, where in strict mode, math
--strict-math=on|off requires brackets. This option may default to on and then
be removed in the future.
-su=on|off Allow mixed units, e.g. 1px+1em or 1px*1px which have units
--strict-units=on|off that cannot be represented.
--global-var='VAR=VALUE' Defines a variable that can be referenced by the file.
--modify-var='VAR=VALUE' Modifies a variable already declared in the file.
-------------------------- Deprecated ----------------
-O0, -O1, -O2 Set the parser's optimization level. The lower
the number, the less nodes it will create in the
tree. This could matter for debugging, or if you
want to access the individual nodes in the tree.
--line-numbers=TYPE Outputs filename and line numbers.
TYPE can be either 'comments', which will output
the debug info within comments, 'mediaquery'
that will output the information within a fake
media query which is compatible with the SASS
format, and 'all' which will do both.
--verbose Be verbose.
If the command line doesn't suite you, Grunt is great at this type of thing. You can configure the grunt-contrib-less plugin to generate inline maps with a config like this:
less: {
options: {
sourceMap:true,
outputSourceFiles: true
},
lessFiles: {
expand: true,
flatten:false,
src: ['**/*.less'],
dest: ['dist/'],
ext: '.css',
}
},
https://github.com/gruntjs/grunt-contrib-less
Example to Create Map and CSS file from Less File
Install latest Node JS and go to command prompt and run npm install less, Now less installed successfully
Go to Command Prompt and move to less file folder that we are going to create
For e.g., I am going to change HelloWorld [Less File]
In Command prompt go to C:\Project\CSS or give the correct path in the below command.
Run following Command in Command Prompt
lessc HelloWorld.less HelloWorld.css --source-map=HelloWorld.css.map –verbose
Now CSS and Map file is generated in the respective folder.
For more reference check the link : royalarun.blogspot.com

Resources