Browse Source

Webpack now runs in development or production mode

`yarn develop` will run Webpack in development mode for easier
debugging. `bundle-build` will run Webpack in production mode and submit
optmized artifacts in the bundle.

webpack.config.js now emits which mode it's selecting to console.log
develop
Rob Colbert 2 years ago
parent
commit
a76ffb555d
  1. 4
      bundle-build
  2. 2
      bundle-submit.js
  3. 8
      webpack.config.js

4
bundle-build

@ -5,7 +5,7 @@
# to that directory.
#
echo "Generating Webpack build artifacts..."
yarn webpack --config webpack.config.js
NODE_ENV=production yarn webpack --config webpack.config.js
#
# Copy game/assets and other static assets dist
@ -36,4 +36,4 @@ rm -Rf dist
echo ""
echo "Game bundle file:"
ls -lh ./bundle/${FILENAME}
ls -lh ./bundle/${FILENAME}

2
bundle-submit.js

@ -41,6 +41,8 @@ import fetch, { FormData, fileFrom } from 'node-fetch';
},
body: formData,
});
const message = await response.text();
console.log(message);
} catch (error) {
console.log('ERROR:', error.message, error);
} finally {

8
webpack.config.js

@ -10,12 +10,14 @@ const __dirname = dirname(fileURLToPath(import.meta.url)); // jshint ignore:line
import MiniCssExtractPlugin from 'mini-css-extract-plugin';
const webpackMode = (process.env.NODE_ENV === 'production') ? 'production' : 'development';
console.log('Webpack mode:', webpackMode);
export default {
entry: {
'game-app': './game/js/game-app.js',
},
// mode: 'development',
mode: 'production',
mode: webpackMode,
output: {
filename: '[name].bundle.js',
path: path.resolve(__dirname, 'dist'),
@ -63,4 +65,4 @@ export default {
},
],
},
};
};

Loading…
Cancel
Save