From 3dee0eba4e2c7e52533fe20c21805bdb91353f63 Mon Sep 17 00:00:00 2001 From: Jamie Curnow Date: Mon, 30 Jul 2018 11:59:28 +1000 Subject: [PATCH] Upgraded to webpack4 --- manager/.babelrc | 12 +++++++++++ manager/gulpfile.js | 27 ++++++++++++----------- manager/package.json | 11 +++++----- manager/webpack.config.js | 45 ++++++++++++++++++++++++++++++++++++++- 4 files changed, 76 insertions(+), 19 deletions(-) create mode 100644 manager/.babelrc diff --git a/manager/.babelrc b/manager/.babelrc new file mode 100644 index 00000000..313497cf --- /dev/null +++ b/manager/.babelrc @@ -0,0 +1,12 @@ +{ + "presets": [ + ["env", { + "targets": { + "browsers": ["Chrome >= 65"] + }, + "debug": false, + "modules": false, + "useBuiltIns": "usage" + }] + ] +} diff --git a/manager/gulpfile.js b/manager/gulpfile.js index 41f3d0c1..7a6694d8 100644 --- a/manager/gulpfile.js +++ b/manager/gulpfile.js @@ -2,18 +2,19 @@ 'use strict'; -const path = require('path'); -const gulp = require('gulp'); -const gutil = require('gulp-util'); -const concat = require('gulp-concat-util'); -const runSequence = require('run-sequence'); -const webpack = require('webpack-stream'); -const imagemin = require('gulp-imagemin'); -const del = require('del'); -const bump = require('gulp-bump'); -const sass = require('gulp-sass'); -const ejs = require('gulp-ejs'); -const PACKAGE = require('./package.json'); +const path = require('path'); +const gulp = require('gulp'); +const gutil = require('gulp-util'); +const concat = require('gulp-concat-util'); +const runSequence = require('run-sequence'); +const webpack = require('webpack'); +const webpackStream = require('webpack-stream'); +const imagemin = require('gulp-imagemin'); +const del = require('del'); +const bump = require('gulp-bump'); +const sass = require('gulp-sass'); +const ejs = require('gulp-ejs'); +const PACKAGE = require('./package.json'); const assets = { views: { @@ -123,7 +124,7 @@ gulp.task('scss', function () { */ gulp.task('js', function () { return gulp.src(assets.js.src) - .pipe(webpack(require('./webpack.config.js'))) + .pipe(webpackStream(require('./webpack.config.js'), webpack)) .pipe(gulp.dest(assets.js.dest)) .on('error', handleError); }); diff --git a/manager/package.json b/manager/package.json index 9673c85c..0f2df432 100644 --- a/manager/package.json +++ b/manager/package.json @@ -19,10 +19,10 @@ "winston": "^2.4.0" }, "devDependencies": { - "@babel/core": "^7.0.0-beta.31", - "@babel/preset-env": "^7.0.0-beta.31", - "@babel/preset-es2015": "^7.0.0-beta.32", - "babel-loader": "^8.0.0-beta.0", + "babel-core": "^6.26.3", + "babel-loader": "^7.1.4", + "babel-minify-webpack-plugin": "^0.3.1", + "babel-preset-env": "^1.7.0", "backbone": "1.3.3", "backbone-virtual-collection": "^0.6.15", "backbone.marionette": "3.4.1", @@ -47,7 +47,8 @@ "prepack-webpack-plugin": "^1.1.0", "run-sequence": "^2.2.0", "underscore": "^1.8.3", - "webpack": "^3.8.1", + "webpack": "^4.12.0", + "webpack-cli": "^3.0.8", "webpack-stream": "^4.0.0", "webpack-visualizer-plugin": "^0.1.11" }, diff --git a/manager/webpack.config.js b/manager/webpack.config.js index 6e051fdd..794225f6 100644 --- a/manager/webpack.config.js +++ b/manager/webpack.config.js @@ -1,7 +1,33 @@ +const path = require('path'); const webpack = require('webpack'); const Visualizer = require('webpack-visualizer-plugin'); module.exports = { + entry: { + main: './src/frontend/js/main.js', + }, + output: { + path: path.resolve(__dirname, 'dist'), + filename: '[name].js', + publicPath: '/' + }, + + module: { + rules: [ + { + test: /\.js$/, + exclude: /node_modules/, + use: { + loader: 'babel-loader' + } + }, + { + test: /\.ejs$/, + loader: 'ejs-loader' + } + ] + }, +/* context: __dirname + '/src/frontend/js', entry: './main.js', output: { @@ -15,7 +41,7 @@ module.exports = { { test: /\.js$/, exclude: /(node_modules|bower_components)/, - loader: 'babel-loader', + loader: 'babel-loader'//, query: { presets: ['@babel/es2015'] } @@ -26,6 +52,22 @@ module.exports = { } ] }, +*/ + plugins: [ + new webpack.ProvidePlugin({ + $: 'jquery', + jQuery: 'jquery', + _: 'underscore' + }), + new Visualizer({ + filename: '../webpack_stats.html' + }), + new webpack.optimize.LimitChunkCountPlugin({ + maxChunks: 1, // Must be greater than or equal to one + minChunkSize: 999999999 + }) + ] +/* plugins: [ new webpack.IgnorePlugin(/^\.\/locale$/, /moment$/), new webpack.optimize.LimitChunkCountPlugin({ @@ -49,4 +91,5 @@ module.exports = { } }) ] +*/ };