diff --git a/tools/webpack b/tools/webpack index a2642e76cc..1b764c7a13 100755 --- a/tools/webpack +++ b/tools/webpack @@ -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', diff --git a/tools/webpack.config.ts b/webpack.config.ts similarity index 94% rename from tools/webpack.config.ts rename to webpack.config.ts index 8dc7691609..465dcd9f6f 100644 --- a/tools/webpack.config.ts +++ b/webpack.config.ts @@ -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", }, };