-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error: Cannot set property 'EvEmitter' of undefined in Foundation Framework including Handlebars templates and Sass/JS compilers #880
Comments
Sorry to hear you are having trouble with Masonry. There's a lot of things going on here that we'll have to sort out. I'm not clear on how you are using gulp.task('bower', function () {
var bowerOverrides = require('gulp-bower-overrides');
return gulp.src('bower_components/*/bower.json')
.pipe(bowerOverrides())
.pipe(gulp.dest('dist'));
}); Are you using another gulp task for Bower files? |
Hello David Thanks for your response. I got this gulp task from Thanks for your help! On Wed, Jul 27, 2016 at 3:47 PM David DeSandro notifications@github.com
|
Unfortunately, attachments will not work with this GitHub issues thread, but you can paste in the code. See thread: #880 |
Okay, here is the code: 'use strict';
import plugins from 'gulp-load-plugins';
import yargs from 'yargs';
import browser from 'browser-sync';
import gulp from 'gulp';
import panini from 'panini';
import rimraf from 'rimraf';
import sherpa from 'style-sherpa';
import yaml from 'js-yaml';
import fs from 'fs';
// Load all Gulp plugins into one variable
const $ = plugins();
// Check for --production flag
const PRODUCTION = !!(yargs.argv.production);
// Load settings from settings.yml
const { COMPATIBILITY, PORT, UNCSS_OPTIONS, PATHS } = loadConfig();
gulp.task('bower', function () {
var bowerOverrides = require('gulp-bower-overrides');
return gulp.src('bower_components/*/bower.json')
.pipe(bowerOverrides())
.pipe(gulp.dest('dist'));
});
function loadConfig() {
let ymlFile = fs.readFileSync('config.yml', 'utf8');
return yaml.load(ymlFile);
}
// Build the "dist" folder by running all of the below tasks
gulp.task('build',
gulp.series(clean, gulp.parallel(pages, sass, javascript, images, copy), styleGuide));
// Build the site, run the server, and watch for file changes
gulp.task('default',
gulp.series('build', server, watch));
// Delete the "dist" folder
// This happens every time a build starts
function clean(done) {
rimraf(PATHS.dist, done);
}
// Copy files out of the assets folder
// This task skips over the "img", "js", and "scss" folders, which are parsed separately
function copy() {
return gulp.src(PATHS.assets)
.pipe(gulp.dest(PATHS.dist + '/assets'));
}
// Copy page templates into finished HTML files
function pages() {
return gulp.src('src/pages/**/*.{html,hbs,handlebars}')
.pipe(panini({
root: 'src/pages/',
layouts: 'src/layouts/',
partials: 'src/partials/',
data: 'src/data/',
helpers: 'src/helpers/'
}))
.pipe(gulp.dest(PATHS.dist));
}
// Load updated HTML templates and partials into Panini
function resetPages(done) {
panini.refresh();
done();
}
// Generate a style guide from the Markdown content and HTML template in styleguide/
function styleGuide(done) {
sherpa('src/styleguide/index.md', {
output: PATHS.dist + '/styleguide.html',
template: 'src/styleguide/template.html'
}, done);
}
// Compile Sass into CSS
// In production, the CSS is compressed
function sass() {
return gulp.src('src/assets/scss/app.scss')
.pipe($.sourcemaps.init())
.pipe($.sass({
includePaths: PATHS.sass
})
.on('error', $.sass.logError))
.pipe($.autoprefixer({
browsers: COMPATIBILITY
}))
// Comment in the pipe below to run UnCSS in production
//.pipe($.if(PRODUCTION, $.uncss(UNCSS_OPTIONS)))
.pipe($.if(PRODUCTION, $.cssnano()))
.pipe($.if(!PRODUCTION, $.sourcemaps.write()))
.pipe(gulp.dest(PATHS.dist + '/assets/css'))
.pipe(browser.reload({ stream: true }));
}
// Combine JavaScript into one file
// In production, the file is minified
function javascript() {
return gulp.src(PATHS.javascript)
.pipe($.sourcemaps.init())
.pipe($.babel())
.pipe($.concat('app.js'))
.pipe($.if(PRODUCTION, $.uglify()
.on('error', e => { console.log(e); })
))
.pipe($.if(!PRODUCTION, $.sourcemaps.write()))
.pipe(gulp.dest(PATHS.dist + '/assets/js'));
}
// Copy images to the "dist" folder
// In production, the images are compressed
function images() {
return gulp.src('src/assets/img/**/*')
.pipe($.if(PRODUCTION, $.imagemin({
progressive: true
})))
.pipe(gulp.dest(PATHS.dist + '/assets/img'));
}
// Start a server with BrowserSync to preview the site in
function server(done) {
browser.init({
server: PATHS.dist, port: PORT
});
done();
}
// Reload the browser with BrowserSync
function reload(done) {
browser.reload();
done();
}
// Watch for changes to static assets, pages, Sass, and JavaScript
function watch() {
gulp.watch(PATHS.assets, copy);
gulp.watch('src/pages/**/*.html').on('change', gulp.series(pages, browser.reload));
gulp.watch('src/{layouts,partials}/**/*.html').on('change', gulp.series(resetPages, pages, browser.reload));
gulp.watch('src/assets/scss/**/*.scss', sass);
gulp.watch('src/assets/js/**/*.js').on('change', gulp.series(javascript, browser.reload));
gulp.watch('src/assets/img/**/*').on('change', gulp.series(images, browser.reload));
gulp.watch('src/styleguide/**').on('change', gulp.series(styleGuide, browser.reload));
} Babel is also in use. This is my first experience and I just threw that gulp task in hoping it would help. Ultimately I was just hoping everything would just work. I successfully installed Owl Carousel for example, so it does work, just not with Masonry. |
@desandro Could you review this issue? |
I've released Masonry v4.1.1 which updates EvEmitter to v1.0.3. Please check that this resolves this issue. |
I don't think I can create a test case on code pen due to the nature of the situation. However... I am trying to include masonry with bower and can't get it to work for the life of me. I proceeded in the following way.
Include via bower:
bower install masonry --save
Bower.json overwritten with the following:
Updated config.yml with the line:
I even tried to include an override in the bower.json file:
And added the following function to my gulpfile.babel.js:
It appears that the pkgd.js is being retrieved as I can see it in the source code. I hope I'm not being a nuisance, but this issue is bugging me.
The text was updated successfully, but these errors were encountered: