Last active
June 22, 2020 23:22
-
-
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.
This file contains hidden or 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
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