var webpack = require('webpack');
var path = require('path');

function resolvePath(relativePath) {
  relativePath = relativePath || './';
  var pathString = path.resolve(__dirname, relativePath);
  console.log('Resolved path: ' + pathString);
  return pathString;
}

module.exports = {
  entry: resolvePath('./main.js'),
  output: {
    filename: 'bundle.js',
    path: resolvePath(),
    publicPath: '/'
  },
  module: {
    rules: [
      {
        test: /\.js$/,
        exclude: /node_modules/,
        use: {
          loader: 'babel-loader',
          options: {
            presets: ['es2015'],
            plugins: []
          }
        }
      },
      {
        test: /\.vue$/,
        use: {
          loader: 'vue-loader'
        }
      },
      {
        test: /\.css$/,
        use: [
          'style-loader',
          'css-loader'
        ]
      }
    ]
  },
  resolve: {
    modules: ["./node_modules"]
  },
  plugins: [
    new webpack.HotModuleReplacementPlugin()
  ],
  devServer: {
    hot: true, // Tell the dev-server we're using HMR
    contentBase: resolvePath(),
    // publicPath: '/',
    port: 10101
  }
}