initial commit
This commit is contained in:
46
webpack/base.js
Executable file
46
webpack/base.js
Executable file
@@ -0,0 +1,46 @@
|
||||
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;
|
||||
Reference in New Issue
Block a user