Upgraded to webpack4

This commit is contained in:
Jamie Curnow 2018-07-30 11:59:28 +10:00
parent 2111d2913b
commit 3dee0eba4e
4 changed files with 76 additions and 19 deletions

12
manager/.babelrc Normal file
View File

@ -0,0 +1,12 @@
{
"presets": [
["env", {
"targets": {
"browsers": ["Chrome >= 65"]
},
"debug": false,
"modules": false,
"useBuiltIns": "usage"
}]
]
}

View File

@ -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);
});

View File

@ -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"
},

View File

@ -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 = {
}
})
]
*/
};