Begin updating dependent libraries to use sync'd webpack builds w/ watches

This commit is contained in:
dannyrb committed 2019-07-05 13:28:49 -04:00
1 parent 3e1e456cc2
commit e250ac0c50
21 files changed
+5303 -1153

No files matched your search

+92
View File
@@ -0,0 +1,92 @@
const HtmlWebpackPlugin = require('html-webpack-plugin');
const path = require('path');
const webpack = require('webpack');
const CopyWebpackPlugin = require('copy-webpack-plugin');
const ExtractCssChunks = require('extract-css-chunks-webpack-plugin');
const SRC_DIR = path.join(__dirname, '../src');
const PUBLIC_DIR = path.join(__dirname, '../public');
const DIST_DIR = path.join(__dirname, '../dist');
// console.log(process);
module.exports = (env, argv) => {
// console.log(env);
// console.log(argv);
return {
entry: {
app: `${SRC_DIR}/index.js`,
},
context: SRC_DIR,
resolve: {
extensions: ['.js', '.jsx', '.json', '*'],
symlinks: true,
},
module: {
rules: [
{
test: /\.jsx?$/,
exclude: [/node_modules/, /packages\\extension/],
loader: 'babel-loader',
options: {
// Find babel.config.js in monorepo root
// https://babeljs.io/docs/en/options#rootmode
rootMode: 'upward',
presets: [
[
'@babel/preset-env',
{
// Do not transform ES6 modules to another format.
// Webpack will take care of that.
modules: false,
},
],
],
},
},
{
test: /\.css$/,
use: [
'style-loader',
ExtractCssChunks.loader,
{ loader: 'css-loader', options: { importLoaders: 1 } },
{
loader: 'postcss-loader',
options: {
config: {
path: './postcss.config.js',
},
},
},
],
},
],
},
plugins: [
// "Public" Folder
new CopyWebpackPlugin([
{
from: PUBLIC_DIR,
to: DIST_DIR,
toType: 'dir',
// Ignore our HtmlWebpackPlugin template file
ignore: ['index.html', '.DS_Store'],
},
]),
new webpack.EnvironmentPlugin(['NODE_ENV']),
new ExtractCssChunks({
filename: '[name].css',
chunkFilename: '[id].css',
// hot: true /* only necessary if hot reloading not function*/
}),
new HtmlWebpackPlugin({
template: `${PUBLIC_DIR}/index.html`,
filename: 'index.html',
templateParameters: {
PUBLIC_URL: '',
REACT_APP_CONFIG: 'config/default.js',
},
// favicon: `${PUBLIC_DIR}/favicon.ico`,
}),
],
};
};
+57
View File
@@ -0,0 +1,57 @@
const webpack = require('webpack');
const merge = require('webpack-merge');
const path = require('path');
const common = require('./webpack.common');
const SRC_DIR = path.join(__dirname, '../src');
const DIST_DIR = path.join(__dirname, '../dist');
module.exports = (env, argv) => {
const commonConfig = common(env, argv);
return merge(commonConfig, {
mode: 'development',
devtool: 'cheap-module-source-map',
output: {
path: DIST_DIR,
filename: 'bundle.js',
publicPath: '/public/',
},
module: {
rules: [
{
test: /\.(gif|jp?g|png|svg|ico)$/i,
use: [
{
loader: 'file-loader',
options: {
name: '[path][name].[ext]',
context: SRC_DIR,
},
},
],
},
{
test: /\.(ttf|eot|woff|woff2)$/i,
use: [
{
loader: 'file-loader',
options: {
name: '[name].[ext]',
},
},
],
},
],
},
plugins: [new webpack.HotModuleReplacementPlugin()],
devServer: {
hot: true,
inline: true,
compress: true,
contentBase: DIST_DIR,
port: 3000,
writeToDisk: true,
},
});
};
+69
View File
@@ -0,0 +1,69 @@
const merge = require('webpack-merge');
const path = require('path');
const workboxPlugin = require('workbox-webpack-plugin');
const common = require('./webpack.common');
const SRC_DIR = path.join(__dirname, '../src');
const DIST_DIR = path.join(__dirname, '../dist');
module.exports = (env, argv) => {
const commonConfig = common(env, argv);
return merge(commonConfig, {
mode: 'production',
stats: {
colors: false,
hash: true,
timings: true,
assets: true,
chunks: true,
chunkModules: true,
modules: true,
children: true,
warnings: true,
},
optimization: {
minimize: true,
sideEffects: true,
},
output: {
path: DIST_DIR,
filename: '[name].bundle.[chunkhash].js',
},
module: {
rules: [
{
test: /\.(gif|jpe?g|png|svg)$/i,
use: [
{
loader: 'url-loader',
options: {
limit: 8192,
},
},
],
},
{
test: /\.(ttf|eot|woff|woff2)$/i,
use: [
{
loader: 'url-loader',
options: {
limit: 50000,
},
},
],
},
],
},
plugins: [
new workboxPlugin.GenerateSW({
swDest: 'sw.js',
clientsClaim: true,
skipWaiting: true,
}),
],
});
};