webpack: Move webpack.config.ts to top level.

We lost the war against top level configuration files many moons ago.
This is what developers and tools expect.  And it seems to be required
for eslint-import-resolver-webpack (there’s ostensibly a {"config":
"tools/webpack.config.ts"} option, but it doesn’t work correctly:
https://github.com/benmosher/eslint-plugin-import/issues/1861).

Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
Anders Kaseorg
2020-08-28 19:36:53 -07:00
committed by Tim Abbott
parent 8dc24e2a20
commit 10bd7a47c4
2 changed files with 12 additions and 14 deletions

View File

@@ -13,7 +13,7 @@ def build_for_prod_or_casper(quiet: bool) -> NoReturn:
"""Builds for production, writing the output to disk"""
webpack_args = ['node', 'node_modules/.bin/webpack-cli',
'--config', 'tools/webpack.config.ts', '-p',
'-p',
'--env', 'production']
if quiet:
webpack_args += ['--display', 'errors-only']
@@ -27,8 +27,6 @@ def build_for_dev_server(host: str, port: str, minify: bool, disable_host_check:
# files as devs make edits and serve new assets on the fly.
webpack_args = ['node', 'node_modules/.bin/webpack-dev-server']
webpack_args += [
'--config',
'tools/webpack.config.ts',
# webpack-cli has a bug where it ignores --watch-poll with
# multi-config, and we don't need the katex-cli part anyway.
'--config-name', 'frontend',

View File

@@ -10,13 +10,13 @@ import TerserPlugin from "terser-webpack-plugin";
import webpack from "webpack";
import BundleTracker from "webpack4-bundle-tracker";
import DebugRequirePlugin from "./debug-require-webpack-plugin";
import assets from "./webpack.assets.json";
import DebugRequirePlugin from "./tools/debug-require-webpack-plugin";
import assets from "./tools/webpack.assets.json";
const cacheLoader: webpack.RuleSetUseItem = {
loader: "cache-loader",
options: {
cacheDirectory: resolve(__dirname, "../var/webpack-cache"),
cacheDirectory: resolve(__dirname, "var/webpack-cache"),
},
};
@@ -25,12 +25,12 @@ export default (env?: string): webpack.Configuration[] => {
const config: webpack.Configuration = {
name: "frontend",
mode: production ? "production" : "development",
context: resolve(__dirname, "../"),
context: __dirname,
entry: assets,
module: {
rules: [
{
test: require.resolve("./debug-require"),
test: require.resolve("./tools/debug-require"),
loader: "expose-loader",
options: {exposes: "require"},
},
@@ -65,8 +65,8 @@ export default (env?: string): webpack.Configuration[] => {
{
test: /\.(js|ts)$/,
include: [
resolve(__dirname, "../static/shared/js"),
resolve(__dirname, "../static/js"),
resolve(__dirname, "static/shared/js"),
resolve(__dirname, "static/js"),
],
use: [cacheLoader, "babel-loader"],
},
@@ -101,7 +101,7 @@ export default (env?: string): webpack.Configuration[] => {
// scss loader
{
test: /\.scss$/,
include: resolve(__dirname, "../static/styles"),
include: resolve(__dirname, "static/styles"),
use: [
{
loader: MiniCssExtractPlugin.loader,
@@ -169,7 +169,7 @@ export default (env?: string): webpack.Configuration[] => {
],
},
output: {
path: resolve(__dirname, "../static/webpack-bundles"),
path: resolve(__dirname, "static/webpack-bundles"),
filename: production ? "[name].[contenthash].js" : "[name].js",
chunkFilename: production ? "[contenthash].js" : "[id].js",
},
@@ -272,12 +272,12 @@ export default (env?: string): webpack.Configuration[] => {
const serverConfig: webpack.Configuration = {
mode: production ? "production" : "development",
target: "node",
context: resolve(__dirname, "../"),
context: __dirname,
entry: {
"katex-cli": "shebang-loader!katex/cli",
},
output: {
path: resolve(__dirname, "../static/webpack-bundles"),
path: resolve(__dirname, "static/webpack-bundles"),
filename: "[name].js",
},
};