* ci: test docs-publish * Require unit tests for dry run * ci: Make sure our docs publish is executable * Try to correct path issue * Try repo prefix * Try as yarn command * Need a workspace to attach to from previous step * Add before we call our bash script * See if we can enforce commands being available -- or just install locally? * Try again * Try SSH * Include username in gh https url * Note regarding failure on PR branches * Remove docs publish from PR workflow * chore: ability to specify an alternative html-template at build time * chore: add command to build demo PWA website output * chore: remove unused CI code * Testing GCP capabilities * syntax * Naming * naming * chore: WebPack output progress that we care about * chore: Only publish the app config we care about * PWA should publish source map * Unused index.html file * chore: Remove unused copy-webpack-plugin ignore * Don't generate source map until we resolve memory issue * ci: attempt to publish with GCP bucket deploy
101 lines
3.1 KiB
JavaScript
101 lines
3.1 KiB
JavaScript
const path = require('path');
|
|
const merge = require('webpack-merge');
|
|
const webpack = require('webpack');
|
|
const webpackCommon = require('./../../../.webpack/webpack.common.js');
|
|
// Plugins
|
|
const { CleanWebpackPlugin } = require('clean-webpack-plugin');
|
|
const CopyWebpackPlugin = require('copy-webpack-plugin');
|
|
const ExtractCssChunksPlugin = require('extract-css-chunks-webpack-plugin');
|
|
const HtmlWebpackPlugin = require('html-webpack-plugin');
|
|
const workboxPlugin = require('workbox-webpack-plugin');
|
|
//
|
|
const SRC_DIR = path.join(__dirname, '../src');
|
|
const DIST_DIR = path.join(__dirname, '../dist');
|
|
const PUBLIC_DIR = path.join(__dirname, '../public');
|
|
// Env Vars
|
|
const HTML_TEMPLATE = process.env.HTML_TEMPLATE || 'index.html';
|
|
const PUBLIC_URL = process.env.PUBLIC_URL || '';
|
|
const APP_CONFIG = process.env.APP_CONFIG || 'config/default.js';
|
|
|
|
module.exports = (env, argv) => {
|
|
const commonConfig = webpackCommon(env, argv, { SRC_DIR, DIST_DIR });
|
|
|
|
return merge(commonConfig, {
|
|
// https://webpack.js.org/configuration/mode/#mode-production
|
|
mode: 'production',
|
|
// Out of memory -- Code Split
|
|
// devtool: 'source-map',
|
|
stats: {
|
|
colors: true,
|
|
hash: true,
|
|
timings: true,
|
|
assets: true,
|
|
chunks: false,
|
|
chunkModules: false,
|
|
modules: false,
|
|
children: false,
|
|
warnings: true,
|
|
},
|
|
optimization: {
|
|
minimize: true,
|
|
sideEffects: true,
|
|
},
|
|
output: {
|
|
path: DIST_DIR,
|
|
filename: '[name].bundle.[chunkhash].js',
|
|
},
|
|
// TODO:
|
|
// Do we need to rip anything out of the more generic common.js we're
|
|
// merging with this?
|
|
plugins: [
|
|
// Longer build. Let's report progress
|
|
new webpack.ProgressPlugin({
|
|
entries: false,
|
|
modules: false,
|
|
modulesCount: 500,
|
|
profile: true,
|
|
}),
|
|
// Clean output.path
|
|
new CleanWebpackPlugin(),
|
|
// "Public" Folder
|
|
new CopyWebpackPlugin([
|
|
{
|
|
from: PUBLIC_DIR,
|
|
to: DIST_DIR,
|
|
toType: 'dir',
|
|
// Ignore our HtmlWebpackPlugin template file
|
|
// Ignore our configuration files
|
|
ignore: ['config/*', 'html-templates/*', '.DS_Store'],
|
|
},
|
|
// Copy over and rename our target app config file
|
|
{
|
|
from: `${PUBLIC_DIR}/${APP_CONFIG}`,
|
|
to: `${DIST_DIR}/app-config.js`,
|
|
},
|
|
]),
|
|
new ExtractCssChunksPlugin({
|
|
filename: '[name].css',
|
|
chunkFilename: '[id].css',
|
|
// hot: true /* only necessary if hot reloading not function*/
|
|
}),
|
|
/**
|
|
* This generates our index.html file from the specified template.
|
|
* This is the easiest way to inject custom configuration and extensions.
|
|
*/
|
|
new HtmlWebpackPlugin({
|
|
template: `${PUBLIC_DIR}/html-templates/${HTML_TEMPLATE}`,
|
|
filename: 'index.html',
|
|
templateParameters: {
|
|
PUBLIC_URL: PUBLIC_URL,
|
|
},
|
|
// favicon: `${PUBLIC_DIR}/favicon.ico`,
|
|
}),
|
|
new workboxPlugin.GenerateSW({
|
|
swDest: 'sw.js',
|
|
clientsClaim: true,
|
|
skipWaiting: true,
|
|
}),
|
|
],
|
|
});
|
|
};
|