| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364 |
- const TransformPages = require("uni-read-pages");
- const execSync = require("child_process").execSync;
- const { webpack } = new TransformPages();
- module.exports = {
- productionSourceMap: true,
- transpileDependencies: ["@dcloudio/uni-ui"],
- configureWebpack: {
- plugins: [
- new webpack.DefinePlugin({
- ROUTES: webpack.DefinePlugin.runtimeValue(() => {
- const tfPages = new TransformPages({
- includes: ["path", "name", "meta", "aliasPath"],
- });
- return JSON.stringify(tfPages.routes);
- }, true),
- }),
- ],
- },
- chainWebpack: (config) => {
- const gitShortKey = execSync("git rev-parse --short HEAD")
- .toString()
- .trim();
- config.module.rule("svg").uses.clear();
- config.module
- .rule("svg")
- .set("type", void 0)
- .set("generator", void 0)
- .use("raw")
- .loader("raw-loader")
- .end();
- config.plugin("define").tap((args) => {
- // mbridge 中的 ENV,不加会打包所有 ENV
- if (Array.isArray(args)) {
- args.forEach((item) => {
- if (item && item["process.env"]) {
- item["process.env"] = Object.assign(item["process.env"], {
- ENV: JSON.stringify(""),
- VUE_APP_SENTRY_RELEASE: JSON.stringify(gitShortKey),
- VUE_APP_API_ORIGIN: JSON.stringify(
- process.env.VUE_APP_API_ORIGIN ||
- (process.env.NODE_ENV === "production"
- ? "https://www.ex.com"
- : process.env.UNI_PLATFORM !== "h5"
- ? "https://test.ex.com"
- : "")
- ),
- });
- }
- });
- }
- return args;
- });
- // process.exit(0);
- },
- };
|