Skip to content

Instantly share code, notes, and snippets.

@NicolaiSchmid
Created May 12, 2018 11:25
Show Gist options
  • Save NicolaiSchmid/61430a2a1f0fd8395413536d539b4aff to your computer and use it in GitHub Desktop.
Save NicolaiSchmid/61430a2a1f0fd8395413536d539b4aff to your computer and use it in GitHub Desktop.
import CopyWebpackPlugin from 'copy-webpack-plugin';
import swPrecachePlugin from 'preact-cli-sw-precache';
import projectVersion from 'project-version';
import path from 'path';
import swPrecacheConfig from './sw-precache-config';
export default function (config, env, helpers) {
// Custom sw-precache-config
swPrecachePlugin(config, swPrecacheConfig);
// This plugin will copy the necessary WebcomponentsJS files to the build directory
config.plugins.push(
new CopyWebpackPlugin([
{
from: path.resolve(
__dirname,
'node_modules/@webcomponents/webcomponentsjs/**/*.js'
),
to: '@webcomponents/webcomponentsjs/[name].[ext]',
},
])
);
const API_CONFIG = {
ACCOUNTS_SERVER: JSON.stringify('http://localhost:81'),
CLIENT_ID: JSON.stringify('XXX'),
};
const definePlugin = helpers.getPluginsByName(config, 'DefinePlugin')[0].plugin;
definePlugin.definitions = Object.assign(
definePlugin.definitions,
Object.assign(
{
VERSION: JSON.stringify(projectVersion),
},
API_CONFIG
)
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment