Skip to content

Instantly share code, notes, and snippets.

@ivan-vilches
Created September 13, 2019 23:59
Show Gist options
  • Save ivan-vilches/15d6f1a6b4b3e64ccc562497eab7cc9b to your computer and use it in GitHub Desktop.
Save ivan-vilches/15d6f1a6b4b3e64ccc562497eab7cc9b to your computer and use it in GitHub Desktop.
const HtmlWebpackPlugin = require('html-webpack-plugin');
const webpack = require('webpack');
const path = require('path');
module.exports = function(){
return {
mode: 'development',
entry: [
'./src/app.js'
],
watch: true,
watchOptions: {
aggregateTimeout: 300, // Process all changes which happened in this time into one rebuild
poll: 1000, // Check for changes every second,
ignored: /node_modules/,
// ignored: [
// '**/*.scss', '/node_modules/'
// ]
},
devtool: 'source-maps',
devServer: {
contentBase: path.join(__dirname, 'src'),
watchContentBase: true,
hot: true,
open: true,
inline: true
},
plugins: [
new HtmlWebpackPlugin({
title: 'Webpack starter project',
template: path.resolve('./src/index.html')
}),
new webpack.HotModuleReplacementPlugin()
],
module: {
rules: [
{
test: /\.scss$/,
use: [
'style-loader',
"css-loader",
"sass-loader"
]
},
{
test: /\.m?js$/,
exclude: /(node_modules|bower_components)/,
use: {
loader: 'babel-loader',
options: {
presets: ['@babel/preset-env']
}
}
},
{
test: /\.(pdf|doc|docx|xls|xlsx|txt|csv|tsv)$/,
use: [
{
loader: "file-loader",
options: {
outputPath: './files',
name: "[name].[ext]",
},
}
]
},
{
test: /\.(jpg|jpeg|gif|png|svg|webp)$/,
use: [
{
loader: "file-loader",
options: {
outputPath: './images',
name: "[name].[ext]",
},
},
]
},
{
test: /\.(woff(2)?|ttf|otf|eot|svg)(\?v=\d+\.\d+\.\d+)?$/,
use: [
{
loader: 'file-loader',
options: {
name: '[name].[ext]',
outputPath: 'fonts/'
}
}
]
},
{
test: /\.html$/,
use: {
loader: 'html-loader',
options: {
attrs: [':src', ':href']
}
}
},
]
}
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment