Skip to content

Commit

Permalink
Merge pull request #452 from guardian/rm/bump-webpack
Browse files Browse the repository at this point in the history
Bump Webpack to version 4
  • Loading branch information
rhystmills authored Oct 5, 2022
2 parents f5af662 + 2f250e9 commit 2289190
Show file tree
Hide file tree
Showing 24 changed files with 11,067 additions and 14,344 deletions.
3 changes: 3 additions & 0 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"plugins": ["@babel/plugin-transform-object-assign"]
}
25,053 changes: 10,864 additions & 14,189 deletions package-lock.json

Large diffs are not rendered by default.

34 changes: 18 additions & 16 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,20 @@
"version": "0.0.1",
"description": "Tool for managing Guardian tags",
"scripts": {
"build": "webpack -p ./public/app.js ./public/build/app.js --config ./public/build_config/webpack.prod.conf.js",
"build-dev": "webpack ./public/app.js ./public/build/app.js --config ./public/build_config/webpack.dev.conf.js --watch",
"build": "webpack --mode production --entry ./public/app.js --output-path ./public/build/ --config ./public/build_config/webpack.prod.conf.js",
"build-dev": "webpack --entry ./public/app.js --output-path ./public/build/ --config ./public/build_config/webpack.dev.conf.js --watch",
"build-icons": "svg-sprite -w 16 -h 16 -v true --view-bust false --view-prefix .i-%s --view-dest . --vs ./public/images/icons.svg --vscss true --view-render-scss-template ./public/images/icons/scssTemplate.scss --view-render-scss-dest ./public/style/_icons.scss ./public/images/icons/*.svg",
"client-dev": "node ./public/devserver.js"
},
"dependencies": {
"babel-core": "^6.0.20",
"babel-loader": "^6.0.1",
"babel-plugin-transform-object-assign": "^6.0.14",
"babel-preset-es2015": "^6.0.15",
"babel-preset-react": "^6.0.15",
"css-loader": "^0.22.0",
"ajv": "^5.3.0",
"babel-loader": "^8.2.5",
"css-loader": "^3.6.0",
"expose-loader": "^0.7.0",
"extract-text-webpack-plugin": "^0.9.1",
"file-loader": "^0.8.5",
"file-loader": "^3.0.1",
"lodash.debounce": "^3.1.1",
"lodash.startcase": "^4.4.0",
"moment": "^2.10.6",
"node-sass": "7.0.0",
"panda-session": "0.1.6",
"phantomjs-prebuilt": "^2.1.14",
"q": "1.4.1",
Expand All @@ -38,22 +33,29 @@
"redux-logger": "^2.0.4",
"redux-thunk": "^1.0.0",
"reqwest": "^2.0.5",
"sass-loader": "^3.1.1",
"sass": "^1.55.0",
"sass-loader": "^8.0.2",
"scribe-editor": "^2.1.1",
"scribe-plugin-keyboard-shortcuts": "^0.1.1",
"scribe-plugin-link-prompt-command": "^0.4.0",
"scribe-plugin-sanitizer": "^0.1.10",
"scribe-plugin-toolbar": "^0.2.2",
"style-loader": "^0.13.0",
"svg-sprite": "^1.2.12",
"style-loader": "^2.0.0",
"svg-sprite": "^1.5.4",
"url-loader": "^0.5.7",
"webpack": "^1.13.1"
"webpack": "^4.46.0"
},
"devDependencies": {
"@babel/core": "^7.19.3",
"@babel/plugin-transform-object-assign": "^7.18.6",
"@babel/preset-env": "^7.19.3",
"@babel/preset-react": "^7.18.6",
"eslint": "^4.18.2",
"eslint-plugin-react": "^3.13.1",
"mini-css-extract-plugin": "^1.6.2",
"react-hot-loader": "^1.3.0",
"webpack-dev-server": "^1.14.1"
"webpack-cli": "^4.10.0",
"webpack-dev-server": "3.1.0"
},
"repository": {
"type": "git",
Expand Down
54 changes: 36 additions & 18 deletions public/build_config/webpack.dev.conf.js
Original file line number Diff line number Diff line change
@@ -1,46 +1,64 @@
var path = require('path');
var ExtractTextPlugin = require('extract-text-webpack-plugin');
const MiniCssExtractPlugin = require("mini-css-extract-plugin");

module.exports = {
devtool: 'source-map',
mode: 'development',
module: {
loaders: [
rules: [
{
test: /\.js$/,
use: [{
loader: "babel-loader",
options: {
presets: ["@babel/preset-env", "@babel/preset-react"]
}
}],
exclude: /node_modules/,
loaders: ['babel?presets[]=es2015&presets[]=react&plugins[]=transform-object-assign']
},
{
test: /\.scss$/,
loader: ExtractTextPlugin.extract('style-loader', 'css-loader?sourceMap!sass-loader?sourceMap')
test: /\.css$/i,
use: [MiniCssExtractPlugin.loader, "css-loader"],
},
{
test: /\.css$/,
loader: ExtractTextPlugin.extract('style-loader', 'css-loader?sourceMap')
test: /\.scss$/,
use: [
MiniCssExtractPlugin.loader,
{
loader: "css-loader",
},
"sass-loader"
]
},
{
test: /\.woff(2)?(\?v=[0-9].[0-9].[0-9])?$/,
loader: "url-loader?mimetype=application/font-woff"
use: [{loader: "url-loader", options: {mimetype: 'application/font-woff'}}]
},
{
test: /\.(ttf|eot|svg|gif)(\?v=[0-9].[0-9].[0-9])?$/,
loader: "file-loader?name=[name].[ext]"
use: [
{
loader: 'file-loader',
options: {
name: '[name].[ext]',
outputPath: 'fonts/'
}
}
]
}
]
},
resolveLoader: {
root: path.join(__dirname, '..', 'node_modules')
},

sassLoader: {
includePaths: [path.resolve(__dirname, '../style')]
},

resolve: {
extensions: ['', '.js', '.jsx', '.json', '.scss']
modules: [
path.join(__dirname, "src"),
"node_modules"
],
// Allows require('file') instead of require('file.js|x')
extensions: ['.js', '.jsx', '.json']
},

plugins: [
new ExtractTextPlugin('main.css')
new MiniCssExtractPlugin({filename: 'main.css'}),
]
};
57 changes: 34 additions & 23 deletions public/build_config/webpack.devserver.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,7 @@ var host = 'https://' + addr;
//

module.exports = {
port: port,
addr: addr,
host: host,
mode: 'development',
entry: {
app: [
'webpack-dev-server/client?' + host,
Expand All @@ -33,43 +31,56 @@ module.exports = {
publicPath: host + '/assets/build/',
filename: 'app.js'
},
resolveLoader: {
modulesDirectories: ['node_modules']
},
module: {
loaders: [
rules: [
{
test: require.resolve('react'),
use: [{ loader: 'expose-loader', options: 'React' }]},
{
test: /\.jsx?$/,
exclude: /node_modules/,
loaders: ['react-hot', 'babel?presets[]=es2015&presets[]=react&plugins[]=transform-object-assign']
test: /\.js$/,
use: [{
loader: "babel-loader",
options: {
presets: ["@babel/preset-env", "@babel/preset-react"]
}
}],
exclude: /node_modules/,
},
{
test: require.resolve('react'),
loader: 'expose?React'
test: /\.css$/,
loaders: ['style-loader', 'css-loader']
},
{
test: /\.scss$/,
loaders: ['style', 'css', 'sass']
},
{
test: /\.css$/,
loaders: ['style', 'css']
loaders: ['style-loader', 'css-loader', 'sass-loader']
},
{
test: /\.woff(2)?(\?v=[0-9].[0-9].[0-9])?$/,
loader: "url-loader?mimetype=application/font-woff"
test: /\.woff(2)?(\?v=[0-9].[0-9].[0-9])?$/,
use: [{loader: "url-loader", options: {mimetype: 'application/font-woff'}}]
},
{
test: /\.(ttf|eot|svg|gif)(\?v=[0-9].[0-9].[0-9])?$/,
loader: "file-loader?name=[name].[ext]"
test: /\.(ttf|eot|svg|gif)(\?v=[0-9].[0-9].[0-9])?$/,
use: [
{
loader: 'file-loader',
options: {
name: '[name].[ext]',
outputPath: 'fonts/'
}
}
]
}
]
]
},
plugins: [
new webpack.HotModuleReplacementPlugin()
],
resolve: {
modules: [
path.join(__dirname, "src"),
"node_modules"
],
// Allows require('file') instead of require('file.js|x')
extensions: ['', '.js', '.jsx', '.json']
extensions: ['.js', '.jsx', '.json']
}
};
67 changes: 40 additions & 27 deletions public/build_config/webpack.prod.conf.js
Original file line number Diff line number Diff line change
@@ -1,55 +1,68 @@
var webpack = require('webpack');
var path = require('path');
var ExtractTextPlugin = require('extract-text-webpack-plugin');
const MiniCssExtractPlugin = require("mini-css-extract-plugin");

module.exports = {
bail: true,
mode: 'production',
output: {
path: path.resolve(__dirname, 'dist'),
filename: 'app.js'
},
module: {
loaders: [
rules: [
{
test: /\.js$/,
test: /\.js$/,
use: [{
loader: "babel-loader",
options: {
presets: ["@babel/preset-env", "@babel/preset-react"]
}
}],
exclude: /node_modules/,
loaders: ['babel?presets[]=es2015&presets[]=react&plugins[]=transform-object-assign']
},
{
test: /\.scss$/,
loader: ExtractTextPlugin.extract('style-loader', 'css-loader!sass-loader')
test: /\.css$/,
use: [MiniCssExtractPlugin.loader, "css-loader"],
},
{
test: /\.css$/,
loader: ExtractTextPlugin.extract('style-loader', 'css-loader')
test: /\.scss$/,
use: [
MiniCssExtractPlugin.loader,
{
loader: "css-loader",
},
"sass-loader"
]
},
{
test: /\.woff(2)?(\?v=[0-9].[0-9].[0-9])?$/,
loader: "url-loader?mimetype=application/font-woff"
use: [{loader: "url-loader", options: {mimetype: 'application/font-woff'}}]
},
{
test: /\.(ttf|eot|svg|gif)(\?v=[0-9].[0-9].[0-9])?$/,
loader: "file-loader?name=[name].[ext]"
use: [
{
loader: 'file-loader',
options: {
name: '[name].[ext]',
outputPath: 'fonts/'
}
}
]
}
]
},
plugins: [
new ExtractTextPlugin('main.css'),
new webpack.DefinePlugin({
'process.env': {
'NODE_ENV': '"production"'
}
}),
new MiniCssExtractPlugin({filename: 'main.css'}),
new webpack.IgnorePlugin(/^\.\/locale$/, /moment$/),
new webpack.optimize.DedupePlugin(),
new webpack.optimize.OccurenceOrderPlugin(),
new webpack.optimize.UglifyJsPlugin({
compress: {
warnings: false
}
})
],
resolveLoader: {
root: path.join(__dirname, '..', 'node_modules')
},

resolve: {
extensions: ['', '.js', '.jsx', '.json']
modules: [
path.join(__dirname, "src"),
"node_modules"
],
extensions: ['.js', '.jsx', '.json']
}
};
4 changes: 2 additions & 2 deletions public/components/MergeTag.react.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import TagSelect from './utils/TagSelect.js';
import CapiStats from './CapiStats/CapiStats.react';
import ConfirmButton from './utils/ConfirmButton.react';
import tagManagerApi from '../util/tagManagerApi';
import showError from '../actions/UIActions/showError';
import { showError } from '../actions/UIActions/showError';
import { browserHistory } from 'react-router'


Expand Down Expand Up @@ -47,7 +47,7 @@ export default class MergeTag extends React.Component {
}

if (this.state.fromTag.id === this.state.toTag.id) {
return (<div> className="merge__warning">
return (<div className="merge__warning">
<div>Cannot merge a tag into itself.</div>
</div>);
}
Expand Down
8 changes: 6 additions & 2 deletions public/devserver.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ var webpack = require('webpack');
var WebpackDevServer = require('webpack-dev-server');
var wpConfig = require('./build_config/webpack.devserver.conf.js');

var port = 8248;
var addr = 'tagmanager-assets.local.dev-gutools.co.uk';
var host = 'https://' + addr;

//
// Webpack
//
Expand Down Expand Up @@ -36,6 +40,6 @@ var wpServer = new WebpackDevServer(webpack(wpConfig), {

//wpServer.use('/public', express.static('public'));

wpServer.listen(wpConfig.port, wpConfig.addr, function() {
console.log('WebpackDevServer listening on port %d', wpConfig.port);
wpServer.listen(port, addr, function() {
console.log('WebpackDevServer listening on port %d', port);
});
2 changes: 1 addition & 1 deletion public/images/icons.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 2289190

Please sign in to comment.