Files
coder/site/webpack.common.ts
G r e y 8fde3ed52f chore: improve eslint, sb, tsc configs (#483)
Summary:

This commit is a bit of a shotgun fix for various project settings.
Realistically, they could've been separate commits, but this is
convenience for just getting things into a green state to unblock
further work.

Details:

- Use our version of TS in vscode plugins
- organize vscode/settings.json
- fix tsconfig.test and tsconfig.prod (removes errors in test files)
- only use prod tsconfig in webpack
- point .eslintrc to both test and prod configs
- cleanup storybook
- running eslint in my workspace was OOMing. I configured
  maxWorkers like we had in v1 to fix this.
- remove .storybook from code coverage
- remove .js files from code coverage --> after moving away
  from Next.js, we don't allowJS in our tsconfig anymore. We only
  use JS for configurations, it's not allowed in src code!
2022-03-18 10:26:13 -04:00

66 lines
1.9 KiB
TypeScript

/**
* @fileoverview This file contains a set of webpack configurations that should
* be shared between development and production.
*/
import * as path from "path"
import { Configuration } from "webpack"
import HtmlWebpackPlugin from "html-webpack-plugin"
const templatePath = path.join(__dirname, "html_templates")
const plugins = [
// The HTML webpack plugin tells webpack to use our `index.html` and inject
// the bundle script, which might have special naming.
new HtmlWebpackPlugin({
template: path.join(templatePath, "index.html"),
publicPath: "/",
}),
]
export const commonWebpackConfig: Configuration = {
// entry defines each "page" or "chunk". Currently, for v2, we only have one bundle -
// a bundle that is shared across all of the UI. However, we may need to eventually split
// like in v1, where there is a separate entry piont for dashboard & terminal.
entry: path.join(__dirname, "src/Main.tsx"),
// modules specify how different modules are loaded
// See: https://webpack.js.org/concepts/modules/
module: {
rules: [
{
test: /\.tsx?$/,
use: [
{
loader: "ts-loader",
options: {
configFile: "tsconfig.prod.json",
},
},
],
exclude: [/node_modules/],
},
],
},
resolve: {
// Let webpack know to consider ts/tsx files for bundling
// See: https://webpack.js.org/guides/typescript/
extensions: [".tsx", ".ts", ".js"],
},
// output defines the name and location of the final bundle
output: {
// The chunk name along with a hash of its content will be used for the
// generated bundle name.
//
// REMARK: It's important to use [contenthash] here to invalidate caches.
filename: "bundle.[contenthash].js",
path: path.resolve(__dirname, "out"),
},
plugins: plugins,
target: "web",
}