47 lines
1.1 KiB
JavaScript
Executable File
47 lines
1.1 KiB
JavaScript
Executable File
import { join } from "path";
|
|
import SpeedMeasurePlugin from "speed-measure-webpack-plugin";
|
|
import TsconfigPathsPlugin from "tsconfig-paths-webpack-plugin";
|
|
|
|
import config from "./config";
|
|
import { basePlugins } from "./options/plugins";
|
|
import rules from "./options/rules";
|
|
|
|
const { devServer } = config;
|
|
console.log("dev server", JSON.stringify(devServer));
|
|
const baseConfig = {
|
|
context: __dirname,
|
|
entry: {
|
|
main: ["../src/index.tsx"],
|
|
},
|
|
output: {
|
|
path: join(config.webpack.rootDir, "dist"),
|
|
publicPath: devServer.isDevServer ? devServer.url : "./",
|
|
filename: devServer.isDevServer
|
|
? "[name].[fullhash].js"
|
|
: "[name].[contenthash].js",
|
|
},
|
|
module: { rules },
|
|
plugins: basePlugins,
|
|
resolve: {
|
|
extensions: [".tsx", ".ts", ".js", ".jsx"],
|
|
plugins: [new TsconfigPathsPlugin({})],
|
|
},
|
|
optimization: {
|
|
runtimeChunk: {
|
|
name: "runtime",
|
|
},
|
|
splitChunks: {
|
|
cacheGroups: {
|
|
commons: {
|
|
test: /[\\/]node_modules[\\/]/,
|
|
name: "vendor",
|
|
},
|
|
},
|
|
},
|
|
},
|
|
};
|
|
|
|
export default process.env.MEASURE
|
|
? new SpeedMeasurePlugin().wrap(baseConfig)
|
|
: baseConfig;
|