From d60ea5e7cb38b5c77a1c5d9b3a771b7a837ddd92 Mon Sep 17 00:00:00 2001 From: Donald Date: Tue, 11 Sep 2018 14:13:38 +0800 Subject: [PATCH] Upgrade webpack to 4.18.0 Add 'watch' and 'dev' npm scripts --- package.json | 10 +++++++--- src/utils/Localization.js | 4 ++-- webpack.config.js | 20 +++++++++++++++++--- 3 files changed, 26 insertions(+), 8 deletions(-) diff --git a/package.json b/package.json index 42eee9d..acd140a 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,9 @@ "description": "ScratchJr", "scripts": { "lint": "eslint src/**", - "build": "webpack" + "watch": "webpack --watch --progress --mode=development --hide-modules", + "dev": "webpack --mode=development --hide-modules", + "build": "webpack --mode=production --hide-modules" }, "author": "Massachusetts Institute of Technology", "license": "BSD-3-Clause", @@ -15,7 +17,7 @@ "devDependencies": { "babel-core": "^6.4.0", "babel-eslint": "^4.1.6", - "babel-loader": "^6.2.1", + "babel-loader": "^7.1.4", "babel-preset-es2015": "^6.3.13", "esformatter": "^0.8.1", "esformatter-braces": "^1.2.1", @@ -25,7 +27,9 @@ "eslint": "^1.10.3", "expose-loader": "^0.7.1", "strip-sourcemap-loader": "0.0.1", - "webpack": "^1.12.11" + "webpack": "^4.18.0", + "webpack-cli": "^3.1.0", + "webpack-notifier": "^1.6.0" }, "dependencies": { "intl": "^1.0.1", diff --git a/src/utils/Localization.js b/src/utils/Localization.js index 5fb0f57..c009a22 100644 --- a/src/utils/Localization.js +++ b/src/utils/Localization.js @@ -19,7 +19,7 @@ require('intl/locale-data/jsonp/sv.js'); require('intl/locale-data/jsonp/th.js'); require('intl/locale-data/jsonp/zh.js'); -require('expose?IntlMessageFormat!intl-messageformat'); +require('expose-loader?IntlMessageFormat!intl-messageformat'); require('intl-messageformat/dist/locale-data/ca'); require('intl-messageformat/dist/locale-data/de'); require('intl-messageformat/dist/locale-data/en'); @@ -94,7 +94,7 @@ export default class Localization { // ensure it's lower case to match filename topLevel = currentLocale.toLowerCase(); } - + // Get messages IO.requestFromServer(localizationRoot + 'localizations/' + topLevel + '.json', (result) => { localizationMessages = JSON.parse(result); diff --git a/webpack.config.js b/webpack.config.js index ed2f814..ec9e14e 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -1,14 +1,22 @@ +var WebpackNotifierPlugin = require('webpack-notifier'); + module.exports = { devtool: 'source-map', entry: { app: './src/entry/app.js' }, output: { - path: './src/build/bundles', + path: __dirname + '/src/build/bundles', filename: '[name].bundle.js' }, + performance: { + hints: false + }, + watchOptions: { + ignored: ["node_modules", "src/build/**/*"] + }, module: { - loaders: [ + rules: [ { test: /\.js$/, include: /node_modules/, @@ -23,5 +31,11 @@ module.exports = { } } ] - } + }, + plugins: [ + new WebpackNotifierPlugin({ + title: "ScratchJr", + alwaysNotify: true + }) + ] };