Skip to content

Commit

Permalink
Adding babel to frontend workflow; Upgradging Webpack to version 2.
Browse files Browse the repository at this point in the history
  • Loading branch information
Steven Bellamy committed Feb 8, 2017
1 parent 12fb56e commit 5f98cb3
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 5,163 deletions.
9 changes: 9 additions & 0 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"presets": ["es2015", "stage-2"],
"env": {
// only happens if NODE_ENV is undefined or set to 'development'
"development": {
// ignored when NODE_ENV is production!
}
}
}
23 changes: 16 additions & 7 deletions config/webpack-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,26 @@ var modernConf = {
// so it needs to be defined here as an external script to ignore for
// unmet dependency references.
externals: { jquery: 'jQuery' },
context: path.join( __dirname, '/../', paths.unprocessed, JS_ROUTES_PATH ),
entry: scriptsManifest.getDirectoryMap( paths.unprocessed +
JS_ROUTES_PATH ),
cache: true,
context: path.join( __dirname, '/../', paths.unprocessed, JS_ROUTES_PATH ),
entry: scriptsManifest.getDirectoryMap( paths.unprocessed + JS_ROUTES_PATH ),
module: {
rules: [ {
test: /\.js$/,
use: [ {
loader: 'babel-loader?cacheDirectory=true'
} ],
exclude: /node_modules/
} ]
},
output: {
path: path.join( __dirname, 'js' ),
path: path.join( __dirname, 'js' ),
filename: '[name]'
},
plugins: [
new webpack.optimize.CommonsChunkPlugin( COMMON_BUNDLE_NAME ),
new webpack.optimize.CommonsChunkPlugin( COMMON_BUNDLE_NAME,
[ COMMON_BUNDLE_NAME ] ),
new webpack.optimize.CommonsChunkPlugin( {
name: COMMON_BUNDLE_NAME
} ),
// Change `warnings` flag to true to view linter-style warnings at runtime.
new webpack.optimize.UglifyJsPlugin( {
compress: { warnings: false }
Expand Down
7 changes: 4 additions & 3 deletions gulp/tasks/scripts.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ var gulpReplace = require( 'gulp-replace' );
var gulpUglify = require( 'gulp-uglify' );
var handleErrors = require( '../utils/handle-errors' );
var paths = require( '../../config/environment' ).paths;
var webpack = require( 'webpack' );
var webpackConfig = require( '../../config/webpack-config.js' );
var webpackStream = require( 'webpack-stream' );
var configLegacy = require( '../config.js' ).legacy;
Expand All @@ -30,7 +31,7 @@ var configLegacy = require( '../config.js' ).legacy;
*/
function _processScript( config, src, dest ) {
return gulp.src( paths.unprocessed + src )
.pipe( webpackStream( config ) )
.pipe( webpackStream( config, webpack ) )
.on( 'error', handleErrors )
.pipe( gulp.dest( paths.processed + dest ) )
.pipe( browserSync.reload( {
Expand Down Expand Up @@ -104,7 +105,7 @@ function scriptsOnDemand() {
*/
function scriptsNonResponsive() {
return gulp.src( paths.unprocessed + '/js/routes/on-demand/header.js' )
.pipe( webpackStream( webpackConfig.onDemandHeaderRawConf ) )
.pipe( webpackStream( webpackConfig.onDemandHeaderRawConf, webpack ) )
.on( 'error', handleErrors )
.pipe( gulpRename( 'header.nonresponsive.js' ) )
.pipe( gulpReplace( 'breakpointState.isInDesktop()', 'true' ) )
Expand Down Expand Up @@ -142,7 +143,7 @@ function scriptsEs5Shim() {
output: {
filename: 'es5-shim.js'
}
} ) )
}, webpack ) )
.pipe( gulpUglify() )
.on( 'error', handleErrors )
.pipe( gulp.dest( paths.processed + '/js/' ) )
Expand Down
Loading

0 comments on commit 5f98cb3

Please sign in to comment.