I'm using gulp for generating CSS from LESS. It has worked perfectly, but now the script seems to ignore the LESS files.
Here is my gulpfile.js (it is definitely correct, since I have not change it in the last time):
// Include Gulp plugins
var gulp = require('gulp'),
less = require('gulp-less'),
watch = require('gulp-watch'),
prefix = require('gulp-autoprefixer'),
plumber = require('gulp-plumber'),
filter = require('gulp-filter'),
rename = require('gulp-rename'),
path = require('path')
;
// Compile LESS to CSS
gulp.task('build-less', function() {
const fileFilter = filter(['*', '!mixins.less', '!variables.less']);
gulp.src('./public/less/*.less') // path to less file
.pipe(fileFilter)
.pipe(plumber())
.pipe(less())
.pipe(gulp.dest('./public/css/')) // path to css directory
;
});
// Get vendors' code
gulp.task('build-vendors', function() {
gulp.src(['./public/components/bootstrap/less/theme.less', './public/components/bootstrap/less/bootstrap.less']) // path to less file
.pipe(plumber())
.pipe(less())
.pipe(rename(function (path) {
//rename all files except 'bootstrap.css'
if (path.basename + path.extname !== 'bootstrap.css') {
path.basename = 'bootstrap-' + path.basename;
}
}))
.pipe(gulp.dest('./public/css')) // path to css directory
;
});
// Run the build process
gulp.task('run', ['build-less', 'build-vendors']);
// Watch all LESS files, then run build-less
gulp.task('watch', function() {
gulp.watch('public/less/*.less', ['run'])
});
// Default will run the 'entry' task
gulp.task('default', ['watch', 'run']);
And here is the call and the output:
$ gulp
[11:21:03] Using gulpfile /var/www/path/to/project/gulpfile.js
[11:21:03] Starting 'watch'...
[11:21:03] Finished 'watch' after 21 ms
[11:21:03] Starting 'build-less'...
[11:21:03] Finished 'build-less' after 13 ms
[11:21:03] Starting 'build-vendors'...
[11:21:03] Finished 'build-vendors' after 4.65 ms
[11:21:03] Starting 'run'...
[11:21:03] Finished 'run' after 5.37 μs
[11:21:03] Starting 'default'...
[11:21:03] Finished 'default' after 6.05 μs
The whatch also works correctly -- when I edit my LESS files I get an output like this:
[11:22:22] Starting 'build-less'...
[11:22:22] Finished 'build-less' after 1.96 ms
[11:22:22] Starting 'build-vendors'...
[11:22:22] Finished 'build-vendors' after 1.78 ms
[11:22:22] Starting 'run'...
[11:22:22] Finished 'run' after 5.08 μs
I also tried to run the build-less directly:
$ gulp build-less
[11:24:06] Using gulpfile /var/www/path/to/project/gulpfile.js
[11:24:06] Starting 'build-less'...
[11:24:06] Finished 'build-less' after 13 ms
No errors, but also no changes at the CSS files.
What might go wrong here and how to fix it?
gulp-filter uses multimatch to match file paths against globbing patterns. The documentation for multimatch has this to say about *:
* matches any number of characters, but not /
Since you're trying to match files with paths like public/less/foo.less (which contain a /) using a single asterisk * doesn't work. You have to use two asterisks **:
gulp.task('build-less', function() {
const fileFilter = filter(['**/*', '!**/mixins.less', '!**/variables.less']);
gulp.src('./public/less/*.less') // path to less file
.pipe(fileFilter)
.pipe(plumber())
.pipe(less())
.pipe(gulp.dest('./public/css/')); // path to css directory
});
Related
My Broccoli builds take up a LOT of time. ~30 seconds to build every time I change a line of js (I mean the incremental re-builds with dev server running, NOT a complete build).
Here's my situation. I have project A which is an ember addon to project B which I npm link in. As I'm developing project A, I am running ember server on project B.
EVERY SINGLE TIME that I make a change to a line of javascript in project A and rebuild, I see that the following files change in project B:
B/dist/assets/vendor.css
B/dist/assets/vendor.js
B/dist/assets/vendor.map
B/dist/assets/B.css
B/dist/assets/B.css.map
My concern is that, because I'm developing a linked package, my broccoli configuration is such that the entire node_modules is recombined into those vendor files.
Is there a way for me to configure ember/broccoli to use a separate file to compile A into and segregate it from the rest of vendor.js? B/dist/assets/A.min.css and B/dist/assets/A.min.js for example?
...or I'm a guessing at the cause of the problem incorrectly?
Thank you so much for your help in advance!
Edit: Here's some extra info as requested
Slowest Nodes (totalTime => 5% ) | Total (avg)
----------------------------------------------+---------------------
Concat (11) | 39239ms (3567 ms)
RecastFilter (280) | 33127ms (118 ms)
Babel (233) | 14099ms (60 ms)
EslintValidationFilter (5) | 12632ms (2526 ms)
LessCompiler (46) | 7191ms (156 ms)
Slowest Nodes (totalTime => 5% ) | Total (avg)
----------------------------------------------+---------------------
SourceMapConcat: Concat: Vendor /asset... (1) | 36270ms
LessCompiler (46) | 4029ms (87 ms)
Here's the index.js (Of project A):
const EngineAddon = require('ember-engines/lib/engine-addon');
const TreeMerger = require('broccoli-merge-trees');
const LessCompiler = require('broccoli-less-single');
const Funnel = require('broccoli-funnel');
const path = require('path');
module.exports = EngineAddon.extend({
name: 'ember-engine-admin-ui',
lazyLoading: false,
treeForVendor(tree) {
let addonTree = this.treeGenerator(path.resolve(this.root, this.options.trees.addon));
let compiledLessTree = new LessCompiler(addonTree, 'styles/addon.less', `styles/${this.name}.css`);
let sidebarCSSTree = new Funnel(path.dirname(require.resolve('sidebar-v2/css/leaflet-sidebar.css')), {
files: ['leaflet-sidebar.css'],
destDir: 'styles'
});
let sidebarJSTree = new Funnel(path.dirname(require.resolve('sidebar-v2/js/leaflet-sidebar.js')), {
files: ['leaflet-sidebar.js'],
destDir: 'js'
});
return new TreeMerger([tree, compiledLessTree, sidebarCSSTree, sidebarJSTree]);
},
included() {
this._super.included.apply(this, arguments);
this.import(`vendor/styles/${this.name}.css`);
this.import('vendor/js/leaflet-sidebar.js');
this.import('vendor/styles/leaflet-sidebar.css');
},
isDevelopingAddon() {
return true;
}
});
When I try to run my test suite I get this error:
uninitialized constant Calabash::Cucumber::VERSION (NameError)
/Users/Dexter/.rvm/gems/ruby-2.1.2/gems/calabash-cucumber-0.14.3/lib/calabash-cucumber/launcher.rb:1041:in `check_server_gem_compatibility'
/Users/Dexter/.rvm/gems/ruby-2.1.2/gems/calabash-cucumber-0.14.3/lib/calabash-cucumber/launcher.rb:645:in `relaunch'
/Users/Dexter/Work/mobile-calabash-test/features/ios/support/01_launch.rb:55:in `Before'
These are my paths before I run the test suite:
export APP=prebuilt/ios/Build/Products/Debug-iphonesimulator/leeo-cal.app
export APP_BUNDLE=$APP
cucumber -p ios
This is my config.yml
ios: PLATFORM=ios -r features/support -r features/ios/support
This is the Before in my 01_launcher.rb
Before do |scenario|
scenario_tags = scenario.source_tag_names
reset_between_scenario = !scenario_tags.include?('#tandem_scenario')
if reset_between_scenario
if LaunchControl.target_is_simulator?
target = LaunchControl.target
simulator = RunLoop::Device.device_with_identifier(target)
bridge = RunLoop::Simctl::Bridge.new(simulator, ENV['APP'])
bridge.reset_app_sandbox
else
LaunchControl.install_app_on_physical_device
end
end
launcher = Calabash::Cucumber::Launcher.launcher
unless launcher.calabash_no_launch?
launcher.relaunch
launcher.calabash_notify(self)
end
end
I'm not really sure what's going on. Is a file not being loaded correctly?
This is the gist to the 01_launch.rb file: https://gist.github.com/DexterV/94b0853e8f784171adce
I am trying to use the puppet file function (not the type) in the following way
class iop_users {
include 's3file::curl'
include 'stdlib'
$secretpath=file('/etc/secret','dev/null')
notify { 'show secretpath':
message =>"secretpath is $secretpath"
}
s3file { '/opt/utab.yaml':
source => "mybucket/$secretpath/utab.yaml",
ensure => 'latest',
}
exec { 'fix perms':
command => '/bin/chmod 600 /opt/utab.yaml',
require => S3file['/opt/utab.yaml']
}
if ( $::virtual == 'xenhvm' and defined(S3file['/opt/utab.yaml']) ) {
$uhash=loadyaml('/opt/utab.yaml')
create_resources(iop_users::usercreate, $uhash)
}
}
If I run this then here is some typical output. The manifest fails as the initial "secret" used to find the path is not loaded
https_proxy=https://puppet:3128 puppet agent -t
Info: Retrieving pluginfacts
Info: Retrieving plugin
Info: Loading facts
Info: Caching catalog for ip-10-40-1-68.eu-west-1.compute.internal
Info: Applying configuration version '1431531382'
Notice: /Stage[main]/Iop_users/S3file[/opt/utab.yaml]/Exec[fetch /opt/utab.yaml]/returns: % Total % Received % Xferd Average Speed Time Time Time Current
Notice: /Stage[main]/Iop_users/S3file[/opt/utab.yaml]/Exec[fetch /opt/utab.yaml]/returns: Dload Upload Total Spent Left Speed
Notice: /Stage[main]/Iop_users/S3file[/opt/utab.yaml]/Exec[fetch /opt/utab.yaml] 0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0
Notice: /Stage[main]/Iop_users/S3file[/opt/utab.yaml]/Exec[fetch /opt/utab.yaml]/returns: curl: (56) Received HTTP code 404 from proxy after CONNECT
Error: curl -L -o /opt/utab.yaml https://s3-eu-west.amazonaws.com/mybucket//utab.yaml returned 56 instead of one of [0]
Error: /Stage[main]/Iop_users/S3file[/opt/utab.yaml]/Exec[fetch /opt/utab.yaml]/returns: change from notrun to 0 failed: curl -L -o /opt/utab.yaml https://s3-eu-west.amazonaws.com/mybucket//utab.yaml returned 56 instead of one of [0]
Notice: /Stage[main]/Iop_users/Exec[fix perms]: Dependency Exec[fetch /opt/utab.yaml] has failures: true
Warning: /Stage[main]/Iop_users/Exec[fix perms]: Skipping because of failed dependencies
Notice: secretpath is
Notice: /Stage[main]/Iop_users/Notify[show secretpath]/message: defined 'message' as 'secretpath is '
Notice: Finished catalog run in 1.28 seconds
However on the same host that the above puppet agent run fails on, if I use "apply" to try it outside of the context of a manifest, it works fine
puppet apply -e '$z=file("/etc/secret") notify { "z": message => $z}'
Notice: Compiled catalog for ip-x.x.x.x.eu-west-1.compute.internal in environment production in 0.02 seconds
Notice: wombat
Notice: /Stage[main]/Main/Notify[z]/message: defined 'message' as 'wombat
'
Notice: Finished catalog run in 0.03 seconds
What am I doing wrong? Are there any better alternative approaches I could make?
As usual I was confused about the way puppet works
Apparently, functions are always executed on the master
So any files being loaded in this way must be on the master
As soon as I added a "/etc/secret" file to the puppetmaster it all worked
The 'rake --trace assets:precompile' command gives the following error:
rake aborted!
Sass::SyntaxError: Invalid CSS after "...ules: $modules ": expected "}", was "!global;"
(in app/assets/stylesheets/foundation_and_overrides.scss:13)
foundation-rails-5.5.0.0/vendor/assets/stylesheets/foundation/_functions.scss:13
foundation-rails-5.5.0.0/vendor/assets/stylesheets/foundation/components/_global.scss:5
foundation-rails-5.5.0.0/vendor/assets/stylesheets/foundation/components/_grid.scss:5
foundation-rails-5.5.0.0/vendor/assets/stylesheets/foundation.scss:9
app/assets/stylesheets/foundation_and_overrides.scss:1327
The error appears to come from line 13 of 'foundation-rails-5.5.0.0/vendor/assets/stylesheets/foundation/_functions.scss'
8 // IMPORT ONCE
9 // We use this to prevent styles from being loaded multiple times for compenents that rely o n other components.
10 $modules: () !default;
11 #mixin exports($name) {
12 // Import from global scope
13 $modules: $modules !global;
14 // Check if a module is already on the list
15 $module_index: index($modules, $name);
16 #if (($module_index == null) or ($module_index == false)) {
17 $modules: append($modules, $name) !global;
18 #content;
19 }
20 }
The SASS syntax looks fine to me, and compiles without error provided I have made no edits to the generated 'app/assets/stylesheets/foundation_and_overrides.scss.' If I make the smallest change to that file, such as the following, the compilation error occurs.
--- a/app/assets/stylesheets/foundation_and_overrides.scss
+++ b/app/assets/stylesheets/foundation_and_overrides.scss
## -14,7 +14,7 ## $base-font-size: 100% !default;
// Since the typical default browser font-size is 16px, that makes the calculation for grid siz
// If you want your base font-size to be a different size and not have it effect grid size too,
// set the value of $em-base to $base-font-size ($em-base: $base-font-size;)
-$em-base: 16px !default;
+$em-base: 17px !default;
// It strips the unit of measure and returns it
#function strip-unit($num) {
Environment is Rails 4.0.8, foundation-rails 5.5.0.0
The foundation-rails gem has set the lower bounds on their Sass dependency to >= 3.2.0, but are using a Sass 3.3 feature (the !global flag). You'll need to specify a dependency for 3.3 for your project.
I also recommend submitting a bug report to the maintainers of foundation-rails.
My HTML File : buildCheck.html
<SCRIPT src="/dojo/dojo.js"></SCRIPT>
<SCRIPT>
dojo.require("dijit.form.Button");
dojo.require("dijit.form.CheckBox");
dojo.require("dijit.form.ComboBox");
dojo.require("dijit.Dialog");
dojo.require("dojo.data.ItemFileReadStore");
dojo.require("my.app");
</SCRIPT>
Command :
>build.bat action=release htmlFiles=../../buildCheck1.html profile=myProfile
Error :
kwArgs.htmlFiles ../../buildCheck1.html
release: Using profile: profiles/myProfile.profile.js
release: Using version number: 0.0.0.dev for the release.
release: Deleting: ../../release/dojo
release: Copying: ../dojo/../dijit to: ../../release/dojo/dijit
release: ********** Not Copied: ../dojo/../dijit
release: Copying: ../dojo/../dojox to: ../../release/dojo/dojox
release: ********** Not Copied: ../dojo/../dojox
release: Copying: ../dojo to: ../../release/dojo/dojo
release: ********** Not Copied: ../dojo
release: Building dojo.js and layer files
js: "./../../dojo/_base/_loader/loader.js", line 423: exception from uncaught Ja
vaScript throw: Error: Could not load 'dojo.i18n'; last tried '../../release/doj
o/dojo/i18n.js'
I am geeting this error if i add the below component
dojo.require("dojo.data.ItemFileReadStore")
after removal the component build is working fine.
What can be the issue?What should i add to avoid this error?
It looks like at the point the error occurs, dojo/i18n has not yet been built. It seems weird to me, that you say it is the ItemFileReadStore - as noting in the dojo.data requires localization.
Try adding a manual dojo.require("dojo.i18n"); to your .html above any dijits reqs
I don't know how you had your files organized, but in my case, I had it like this:
- js
- dojo_require.js (the file with "dojo.require" statements, just like your "buildCheck.html")
- dojo-release-1.6.1-src (dojo files)
- dijit
- dojo
- dojox
- util
- buildscripts
- release
And I faced exactly the same problem. I figured out this happens, when the html file contains any require that loads something from the 'dojo' folder. dojo.require("dijit.<*>") is fine, dojo.require("dojox.<*>") is fine, but dojo.require("dojo.<*>") causes the build script to use an incorrect relative path to dojo. I was getting the same output as you:
release: Deleting: ../../release/dojo
release: Copying: ../dojo/../dijit to: ../../release/dojo/dijit
But I should have got something like Copying: ../../dojo/../dijit to: ../../release/dojo/dijit instead. One ../ was missing.
Now, it is probably a bug (I am lazy to investigate it further), and since 1.6 is a pretty old version of dojo, the correct fix should be to upgrade. But since at some occasions, it is just too much pain, here is a dirty hack that made it possible for my buildscript to run and finish:
In dojo-release-1.6.1-src/util/buildscripts/build.js, on the line 107, add this line:
prefixPath = '../' + prefixPath;
So that the entire block of code looks like this:
for(var i = 0; i < prefixes.length; i++){
var prefixName = prefixes[i][0];
var prefixPath = prefixes[i][1];
prefixPath = '../' + prefixPath; // HACK!
var finalPrefixPath = prefixPath;
if(finalPrefixPath.indexOf(".") == 0 && prefixName != "dojo"){
finalPrefixPath = dojoPrefixPath + "/" + prefixPath;
}
_copyToRelease(prefixName, finalPrefixPath, kwArgs, buildLayers);
if(kwArgs.symbol){
var releasePath = kwArgs.releaseDir + "/" + prefixName.replace(/\./g, "/");
buildUtil.insertSymbols(releasePath, kwArgs);
}
}