const { smart } = require("webpack-merge");
const HtmlPlugin = require("html-webpack-plugin");
const base = require("./webpack.base.js");
const path = require("path");

module.exports = smart(base, {
  mode: "development",
  entry: path.resolve(__dirname, "../example/index.jsx"),
  output: {
    path: path.resolve(__dirname, "lib"),
    filename: "bundle.js",
  },
  devtool: "source-map",
  module: {
    rules: [
      {
        // exclude: /node_modules/,
        test: /\.css$/,
        loader: ["style-loader", "css-loader"],
      },
      {
        exclude: /node_modules/,
        test: /\.less$/,
        loader: [
          "style-loader",
          {
            loader: "css-loader",
            options: {
              modules: {
                localIdentName: "[name]_[local]_[hash:base64:5]",
              },
            },
          },
          "less-loader",
        ],
      },
    ],
  },
  plugins: [
    new HtmlPlugin({
      template: "./example/index.html",
    }),
  ],
  resolve: {
    extensions: [".js", ".jsx"],
  },
  devServer: {
    contentBase: "./lib",
    port: 8080,
    hot: true,
  },
});
