Skip to content

Instantly share code, notes, and snippets.

@revanth0212
Created October 27, 2022 15:38
Show Gist options
  • Save revanth0212/9ada164bd9b64ab7dbf8ecf1a4756f4e to your computer and use it in GitHub Desktop.
Save revanth0212/9ada164bd9b64ab7dbf8ecf1a4756f4e to your computer and use it in GitHub Desktop.
Webpack config to build mesh config artifacts into single JS file
const path = require("path");
const webpack = require("webpack");
const entry = "./src/actions/mesh/handler.js";
module.exports = {
entry,
target: "node",
output: {
library: {
type: "commonjs",
},
path: path.resolve(__dirname, "actions", "mesh"),
filename: "handler.js",
},
resolve: {
extensions: [".ts", ".js", ".json", ".mjs", ".graphql"],
},
plugins: [
new webpack.optimize.LimitChunkCountPlugin({
maxChunks: 1,
}),
],
module: {
rules: [
{ test: /\.js$/, use: "babel-loader" },
{
test: /\.ya?ml$/,
type: "json",
use: "yaml-loader",
},
{
test: /\.html$/i,
loader: "html-loader",
},
{
test: /\.ts?$/,
use: "ts-loader",
exclude: /node_modules/,
},
{
test: /\.m?js/,
resolve: {
fullySpecified: false,
},
},
{
test: /\.(graphql|gql)$/,
exclude: /node_modules/,
loader: "graphql-tag/loader",
},
],
},
mode: process.env.NODE_ENV || "production",
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment