Skip to content
Snippets Groups Projects
webpack.config.js 1.04 KiB
Newer Older
  • Learn to ignore specific revisions
  • const HtmlWebpackPlugin = require('html-webpack-plugin');
    
    const HtmlWebpackInlineSourcePlugin = require('html-webpack-inline-source-plugin');
    const WebpackCleanPlugin = require('webpack-clean');
    
    module.exports = {
      mode: 'production',
      entry: {
    
        'viamapi-client': ['core-js/fn/promise', './src/viamapi-client.js'],
    
        'viamapi-iframe': ['babel-polyfill', './temp/viamapi-iframe.js'],
    
      plugins: [
    
        new HtmlWebpackPlugin({  // Also generate a test.html
          filename: 'viamapi-iframe.html',
          template: 'src/viamapi-iframe.html',
          chunks: ['viamapi-iframe'],
          inlineSource: '.(js)$'
        }),
        new HtmlWebpackInlineSourcePlugin(),
        new WebpackCleanPlugin('dist/viamapi-iframe.js')
    
      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']
              }
            }
          }
        ]