Skip to content

Instantly share code, notes, and snippets.

@musamusa
Created November 25, 2021 03:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save musamusa/52de99a17d32e3bc6e051ee4f82870d4 to your computer and use it in GitHub Desktop.
Save musamusa/52de99a17d32e3bc6e051ee4f82870d4 to your computer and use it in GitHub Desktop.
"use strict";
const Path = require("path");
const Webpack = require("webpack");
const HtmlWebpackPlugin = require("html-webpack-plugin");
const ExtractTextPlugin = require("extract-text-webpack-plugin");
const ExtractSASS = new ExtractTextPlugin("styles/bundle.[hash].css");
const port = 3001;
module.exports = (options) => {
const dest = Path.join(__dirname, "dist");
let webpackConfig = {
mode: 'development',
devtool: "eval-cheap-source-map",
entry: ["./src/scripts/index.js"],
output: {
path: dest,
filename: "bundle.[hash].js",
},
plugins: [
new HtmlWebpackPlugin({
template: "./src/index.html",
minify: false,
}),
],
module: {
rules: [
{
test: /\.js$/,
exclude: /(node_modules|bower_components)/,
use: {
loader: "babel-loader",
options: {
presets: ["env"],
},
},
},
],
},
};
webpackConfig.plugins.push(new Webpack.HotModuleReplacementPlugin());
webpackConfig.module.rules.push({
test: /\.s?css$/i,
use: [
"style-loader",
"css-loader?sourceMap=true",
{
loader: "sass-loader",
options: { includePaths: [Path.join(__dirname, "src/styles")] },
},
],
});
webpackConfig.devServer = {
static: "/",
hot: true,
port,
// inline: true,
};
return webpackConfig;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment