webpack.config.js

If you need a configuration file you can create a webpack.config.js file in the root folder.
If the file is found webpack will automatically use it.


module.exports = { 
  devtool: "source-map",
  entry: __dirname + '/index.js',
  output: {
      filename: 'webpackbundle.js'
   },
  module: {
    rules: [
      {
        test: /.js?$/,
        exclude: /node_modules/,
        use: {
          loader: 'babel-loader'
        }
      }
    ]
  }
};

var HTMLWebpackPlugin = require('html-webpack-plugin');   
var HTMLWebpackPluginConfig = new HTMLWebpackPlugin({
   template: __dirname + '/code/index.html',
   filename: 'index.html',
   inject: 'body'
});

module.exports = {
   entry: __dirname + '/code/index.tsx',
   output: {
      filename: 'webpackbundle.js',
      path: __dirname + '/build'
   },
   module: {
      rules: [
          {
             test: /.tsx$/,
             exclude: /node_modules/,
             use: {
                loader: 'babel-loader',
                options: {
                   presets: ['@babel/preset-react']
                }
             }
          } ,
          {
             test: /.tsx$/,
             loader: 'ts-loader',
             exclude: /node_modules/,
          }
      ]
   },
   plugins: [HTMLWebpackPluginConfig]
};



© 2020 Better Solutions Limited. All Rights Reserved. © 2020 Better Solutions Limited TopPrevNext