Skip to content

Instantly share code, notes, and snippets.

@clintandrewhall
Created April 12, 2020 17:23
Show Gist options
  • Save clintandrewhall/fd0826f92e772469ee847feaa0414bd6 to your computer and use it in GitHub Desktop.
Save clintandrewhall/fd0826f92e772469ee847feaa0414bd6 to your computer and use it in GitHub Desktop.
tiny-json-http/issues/14 example
const path = require('path');
const fs = require('fs');
const CopyPlugin = require('copy-webpack-plugin');
const lib = path.resolve(__dirname, 'lib/http');
const entry = {};
const copies = [];
const externals = { '@architect/functions': 'commonjs @architect/functions' };
fs.readdirSync(lib).forEach((mod) => {
if (mod.startsWith('.')) {
return;
}
const lib = `./lib/http/${mod}`;
const src = `src/http/${mod}`;
entry[`${src}/index`] = lib;
// Add copying rules
copies.push({
from: lib,
to: src,
ignore: ['*.ts'],
});
});
module.exports = {
mode: 'development',
entry,
output: {
path: __dirname,
filename: '[name].js',
},
resolve: {
extensions: ['.ts', '.tsx', '.js'],
},
externals,
node: {
fs: 'empty',
},
module: {
rules: [
{
test: /\.(ts|js)x?$/,
exclude: /node_modules/,
use: {
loader: 'babel-loader',
},
},
],
},
plugins: [new CopyPlugin(copies)],
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment