无法从react项目中删除源地图

时间:2019-05-19 11:22:36

标签: reactjs react-scripts

我想禁用源映射,以便我的代码不会出现在部署链接源中。正如您将在屏幕截图中看到的那样,我更改了build并创建了.env文件,但该文件仍然无效,并且代码仍然可见。同样,.env文件也不会提交,并显示Untracked FilesScreenShot

2 个答案:

答案 0 :(得分:1)

尝试在构建后删除地图文件。

module.exports.shipments = async (event) => {
    const axios = require("axios");
    let data = JSON.parse(event.body);
    let url = data.apiURL + "/api/1.1/wf/bulkshipments/initialize";
    let patchURL = data.apiURL + "/api/1.1/obj/company/" + data.companyID;

    data.shipments.forEach((item, index, array) => {
        axios.post(url,{
        batchID: data.batchID,
        companyID: data.companyID,
        shipment: item})
    });

    return {
      statusCode: 200,
      body: JSON.stringify({
        message: 'Created successfully!',
        totalShipments: data.shipments.length,
      }, null, 2),
    };
};

答案 1 :(得分:0)

我将当前的"build"替换为"build": "react-scripts build && rm build/static/js/*.map && rm build/static/css/*.map",它可以正常工作。我会从源代码中删除js和CSS。