Skip to content

Instantly share code, notes, and snippets.

@trulysinclair
Last active June 22, 2020 23:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save trulysinclair/004b513a1461a4fe0e8a8b0faaafb911 to your computer and use it in GitHub Desktop.
Save trulysinclair/004b513a1461a4fe0e8a8b0faaafb911 to your computer and use it in GitHub Desktop.
This is part of my article Yarn 2 and TypeScript: Adding Webpack, https://medium.com/@thegrimsilence/yarn-2-and-typescript-adding-webpack-9dd9d24001f7.
import { Configuration } from "webpack";
import { resolve } from "path";
// Unfortunately pnpwp lacks TypeScript typings.
const PnpPlugin = require("pnp-webpack-plugin");
const isProductionBuild: boolean = process.env.NODE_ENV == "production";
const config: Configuration = {
entry: {
app: resolve(__dirname, "path-to-your-file.js"),
},
mode: isProductionBuild ? "production" : "development",
module: {
rules: [
{
enforce: "pre",
test: /\.js$/,
loader: "source-map-loader",
},
],
},
output: {
filename: "[name].js",
path: resolve(__dirname, "dist"),
},
// This tells Webpack how to resolve dependencies
resolve: {
plugins: [PnpPlugin],
},
// This tells Webpack how to resolve loaders
resolveLoader: {
plugins: [PnpPlugin.moduleLoader(module)],
},
target: "async-node",
};
export default config;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment