Created
November 25, 2021 03:36
-
-
Save musamusa/52de99a17d32e3bc6e051ee4f82870d4 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"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