Skip to content

Commit

Permalink
update jspm configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
guybedford committed Mar 18, 2015
1 parent f5250d0 commit 09ccd43
Showing 1 changed file with 2 additions and 8 deletions.
10 changes: 2 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -76,18 +76,12 @@
],
"jspm": {
"main": "js/bootstrap",
"directories": {
"example": "examples",
"lib": "dist"
},
"shim": {
"js/bootstrap": {
"imports": "jquery",
"deps": "jquery",
"exports": "$"
}
},
"buildConfig": {
"uglify": true
}
"files": ["css", "fonts", "js"]
}
}

3 comments on commit 09ccd43

@JacopKane
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@guybedford Can i ask why did you decided for excluding less files?

@guybedford
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JacopKane happy to add them in if you need, but the idea is that packages are directly consumable in jspm, and currently there is no easy LESS workflow via the jspm resolver.

@JacopKane
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@guybedford Well I believe it's good for jspm since less files can be also used as static assets as well. Although I don't want to be only reason causing this change =) I was just curious.

Currently I'm using bower endpoint for jspm as a workaround since it's also including less files.

And btw this is how I'm working with gulp/systemjs and jspm. Will improve it soon maybe as a plugin.

import gulp from 'gulp';
import LoadPlugins from 'gulp-load-plugins';
import runSequence from 'run-sequence';
import paths from '../paths';
import System from 'systemjs';
import LessPluginCleanCSS from 'less-plugin-clean-css';
import LessPluginAutoPrefix from 'less-plugin-autoprefix';
import lessInlineUrls from 'less-plugin-inline-urls';


//(...)

const plugins = new LoadPlugins();
const loader = Loader || System;
const vendorPaths = [];

gulp.task('loader-config', () => {
  return loader.import(`${paths.js}/config.js`);
});

gulp.task('vendor-paths', ['loader-config'], () => {
  let vendorPromises = [];
  Object.keys(loader.map).forEach(key => {
    let promise = new Promise((resolve, reject) => {
      loader.normalize(key)
        .then(path => {
          path = path
            .replace('file:\/\/', '')
            .replace('.js', '');
          vendorPaths.push(path);
          resolve(path);
        });
    });
    vendorPromises.push(promise);
  });

  return Promise.all(vendorPromises);
});

gulp.task('build-less', ['vendor-paths'], () => {
  let lessCleanCss = new LessPluginCleanCSS({
    advanced: true
  }),
  lessAutoPrefix = new LessPluginAutoPrefix({
    browsers: ["last 2 versions"]
  });

  return gulp.src(paths.source.less)
    .pipe(plugins.plumber())
    .pipe(plugins.changed(paths.output.less, {
      extension: '.less'
    }))
    .pipe(plugins.less({
      paths   : [
        paths.less,
        paths.vendor
      ].concat(vendorPaths),
      plugins : [ lessAutoPrefix, lessInlineUrls, lessCleanCss ]
    }))
    .pipe(plugins.sourcemaps.write({
      sourceRoot : paths.sourceMapRelativePath
    }))
    .pipe(plugins.plumber.stop())
    .pipe(gulp.dest(paths.output.less));
});

Please sign in to comment.