Skip to content
Snippets Groups Projects
webpack.config.js 1.06 KiB
const HtmlWebpackPlugin = require("html-webpack-plugin");
const HtmlWebpackInlineSourcePlugin = require("html-webpack-inline-source-plugin");
const CleanWebpackPlugin = require("clean-webpack-plugin");

module.exports = {
  entry: {
    "viamapi-client": ["core-js/fn/promise", "./src/viamapi-client.js"],
    "viamapi-iframe": [
      "babel-polyfill",
      "webcrypto-shim",
      "./src/iframe/viamapi-iframe.js"
    ]
  },
  plugins: [
    new HtmlWebpackPlugin({
      // Also generate a test.html
      filename: "viamapi-iframe.html",
      template: "src/iframe/viamapi-iframe.html",
      chunks: ["viamapi-iframe"],
      inlineSource: ".(js)$"
    }),
    new CleanWebpackPlugin(),
    new HtmlWebpackInlineSourcePlugin()
  ],
  module: {
    rules: [
      {
        test: /\.m?js$/,
        // We have to transpile every dependency to make it work for older browsers. (IE 11)
        //exclude: /node_modules/,
        use: {
          loader: "babel-loader",
          options: {
            presets: ["@babel/preset-env"]
          }
        }
      }
    ]
  }
};