var webpackStream = require('webpack-stream');
var webpack2 = require('webpack');
var named = require('vinyl-named');
+ var sourcemaps = require('gulp-sourcemaps');
+var utils = require('../utils.js');
var CONFIG = require('../config.js');
-// Compiles JavaScript into a single file
-gulp.task('javascript', ['javascript:foundation', 'javascript:deps', 'javascript:docs']);
-
-// NOTE: This sets up all imports from within Foundation as externals, for the purpose
+// ----- WEBPACK CONFIGURATION -----
+//
+// The following sets up all imports from within Foundation as externals, for the purpose
// of replicating the "drop in dist file" approach of prior versions.
// THIS IS NOT RECOMMENDED FOR MOST USERS. Chances are you either want everything
// (just throw in foundation.js or foundation.min.js) or you should be using a build
]
},
output: {
- // ---
- // FIXME: to resolve before the next release
- // Temporary disable UMD bundling, waiting for a way to import plugins are externals
- // See https://github.com/zurb/foundation-sites/pull/10903
- // ---
- // libraryTarget: 'umd',
+ libraryTarget: 'umd',
- }
+ },
+ // https://github.com/shama/webpack-stream#source-maps
+ devtool: 'source-map'
}
+// ----- TASKS -----
+//
+
+// Compiles JavaScript into a single file
+gulp.task('javascript', ['javascript:foundation', 'javascript:deps', 'javascript:docs']);
+
// Core has to be dealt with slightly differently due to bootstrapping externals
-// and the dependency on foundation.util.core
+// and the dependency on foundation.core.utils
//
gulp.task('javascript:plugin-core', function() {
return gulp.src('js/entries/plugins/foundation.core.js')
.pipe(named())
- .pipe(webpackStream(webpackConfig, webpack2))
+ .pipe(sourcemaps.init())
+ .pipe(webpackStream(Object.assign({}, webpackConfig, {
+ output: webpackOutputAsExternal,
+ }), webpack2))
+ .pipe(sourcemaps.write('.'))
.pipe(gulp.dest('_build/assets/js/plugins'));
});
gulp.task('javascript:plugins', ['javascript:plugin-core'], function () {
return gulp.src(['js/entries/plugins/*.js', '!js/entries/plugins/foundation.core.js'])
.pipe(named())
- .pipe(webpackStream(Object.assign({}, webpackConfig, { externals: pluginsAsExternals }), webpack2))
+ .pipe(sourcemaps.init())
+ .pipe(webpackStream(Object.assign({}, webpackConfig, {
+ externals: webpackExternalPlugins,
+ output: webpackOutputAsExternal,
+ }), webpack2))
+ .pipe(sourcemaps.write('.'))
.pipe(gulp.dest('_build/assets/js/plugins'));
});
gulp.task('javascript:foundation', ['javascript:plugins'], function() {
return gulp.src('js/entries/foundation.js')
.pipe(named())
+ .pipe(sourcemaps.init())
.pipe(webpackStream(webpackConfig, webpack2))
+ .pipe(sourcemaps.write('.'))
.pipe(gulp.dest('_build/assets/js'));
});
-//gulp.task('javascript:foundation', function() {
-// return gulp.src(CONFIG.JS_FILES)
-// .pipe(babel()
-// .on('error', onBabelError))
-// .pipe(gulp.dest('_build/assets/js/plugins'))
-// .pipe(concat('foundation.js'))
-// .pipe(gulp.dest('_build/assets/js'));
-//});
gulp.task('javascript:deps', function() {
return gulp.src(CONFIG.JS_DEPS)