Created
April 12, 2020 17:23
-
-
Save clintandrewhall/fd0826f92e772469ee847feaa0414bd6 to your computer and use it in GitHub Desktop.
tiny-json-http/issues/14 example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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