Skip to content

Instantly share code, notes, and snippets.

@bojanv55
Last active July 16, 2021 18:41
Show Gist options
  • Save bojanv55/4f07c3837eccd657f2a47a30afb65e55 to your computer and use it in GitHub Desktop.
Save bojanv55/4f07c3837eccd657f2a47a30afb65e55 to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>PFC</title>
<link rel="stylesheet" type="text/css" href="loader.css" />
</head>
<body>
<header>
<h1>header</h1>
</header>
</body>
</html>
.loader{
background-color: red;
}
{
"name": "rfc",
"version": "1.0.0",
"description": "",
"private": true,
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"watch": "webpack --watch",
"start": "webpack serve --open",
"build": "webpack"
},
"keywords": [],
"author": "",
"license": "ISC",
"devDependencies": {
"css-loader": "^6.0.0",
"html-loader": "^2.1.2",
"html-webpack-plugin": "^5.3.2",
"mini-css-extract-plugin": "^2.1.0",
"sass": "^1.35.2",
"sass-loader": "^12.1.0",
"style-loader": "^3.1.0",
"webpack": "^5.44.0",
"webpack-cli": "^4.7.2",
"webpack-dev-server": "^3.11.2"
}
}
const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
module.exports = {
mode: 'development',
entry: './src/index.js',
devtool: 'inline-source-map',
devServer: {
contentBase: './dist',
},
plugins: [
new HtmlWebpackPlugin({
title: 'Development',
template: 'src/index.html'
}),
new MiniCssExtractPlugin(),
],
output: {
filename: '[name].bundle.js',
path: path.resolve(__dirname, 'dist'),
clean: true //clean dist folder before each build
},
module: {
rules: [
{
test: /\.html$/i,
use: ['html-loader'],
},
{
test: /\.css$/i,
use: [MiniCssExtractPlugin.loader, 'css-loader'],
},
{
test: /\.scss$/i,
use: [MiniCssExtractPlugin.loader, 'css-loader','sass-loader'],
},
{
test: /\.(png|svg|jpg|jpeg|gif|ico)$/i,
type: 'asset/resource',
},
{
test: /\.(woff|woff2|eot|ttf|otf)$/i,
type: 'asset/resource',
},
],
},
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment