防止Webpack输出

时间:2018-07-31 12:55:43

标签: webpack webpack-4

作为Web应用程序中常规过程的一部分,我正在使用Webpack捆绑一些代码并上传到S3。每次发生这种情况时,Webpack都会在dist/文件夹中创建一个捆绑文件。我实际上不希望发生这种情况,因为我只需要将文件上传到S3。当我删除输出选项时,它只是使用默认名称(main.js)创建一个包。有没有办法完全防止输出?

这是我当前的配置:

(fileID, injection) => ({
    // Where to start bundling
    entry: [
      "babel-regenerator-runtime",
      "./lib/snippets/src/sync.js",
    ],

    // Where to output
    output: {
      // Capture name from the entry using a pattern
      filename: `${fileID}.js`
    },

    // How to resolve encountered imports
    module: {
      rules: [
        {
          test: /\.js$/,
          use: {
            loader: "babel-loader"
          },
          exclude: /node_modules/
        }
      ]
    },

    //
    stats: "errors-only",

    // What extra processing to perform
    plugins: [
      // This plugin takes code as a string and inserts into the bundle
      new InjectPlugin(
        function() {
          return injection;
        },
        {
          order: ENTRY_ORDER.First
        }
      ),
      new S3Uploader({
        s3Options: {
          accessKeyId: process.env.AWS_ACCESS_KEY,
          secretAccessKey: process.env.AWS_SECRET_KEY,
          region: "eu-west-2"
        },
        s3UploadOptions: {
          Bucket: process.env.S3_BUCKET
        }
      })
    ],

    // Adjust module resolution algorithm
    resolve: {}
  })

0 个答案:

没有答案