Revision 74e50e1a12a0e44aa31c82408a90dcd4dbffa548 authored by amunozpomer on 04 March 2019, 16:10:29 UTC, committed by amunozpomer on 04 March 2019, 16:10:29 UTC
1 parent cf56f8f
Raw File
webpack.config.js
const path = require(`path`)
const CleanWebpackPlugin = require(`clean-webpack-plugin`)

const commonPublicPath = `/dist/` //'/gxa/resources/js-bundles/'

module.exports = {
  entry: {
    heatmapHighcharts: ['@babel/polyfill', 'whatwg-fetch', './src/Main.js'],
    experimentPicker: ['@babel/polyfill', 'whatwg-fetch', './html/ExperimentPicker.js'],
  },

  plugins: [
    new CleanWebpackPlugin([`dist`])
  ],

  output: {
    library: `[name]`,
    filename: `[name].bundle.js`,
    publicPath: commonPublicPath
  },

  optimization: {
    splitChunks: {
      cacheGroups: {
        commons: {
          test: /[\\/]node_modules[\\/]/,
          name: `vendors`,
          chunks: `all`
        }
      }
    }
  },

  module: {
    rules: [
      {
        test: /\.js$/i,
        exclude: /node_modules\//,
        use: `babel-loader`
      },
      {
        test: /\.(jpe?g|png|gif)$/i,
        use: [
          {
            loader: `file-loader`,
            options: { query: { name: `[hash].[ext]`, hash: `sha512`, digest: `hex` } }
          },
          {
            loader: `image-webpack-loader`,
            options: {
              query: {
                bypassOnDebug: true,
                mozjpeg: { progressive: true },
                gifsicle: { interlaced: true },
                optipng: { optimizationLevel: 7 }
              }
            }
          }
        ]
      },
      {
        test: /\.(svg)$/i,
        use: [
          {
            loader: `file-loader`,
            options: { query: { name: `[hash].[ext]`, hash: `sha512`, digest: `hex` } }
          }
        ]
      },
    ]
  },

  devServer: {
    port: 9000,
    contentBase: path.resolve(__dirname, `html`),
    publicPath: commonPublicPath
  }
}
back to top