Created
March 30, 2018 20:27
-
-
Save caesaneer/9cf2428dda9289348b7d6ea460762da8 to your computer and use it in GitHub Desktop.
Webpack 4 Config
This file contains 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
const path = require('path') | |
const webpack = require('webpack') | |
const HtmlWebPackPlugin = require('html-webpack-plugin') | |
const ErrorOverlayPlugin = require('error-overlay-webpack-plugin') | |
module.exports = { | |
devtool: 'cheap-module-source-map', | |
mode: 'development', | |
entry: { | |
index: './src/index.js', | |
}, | |
output: { | |
path: path.resolve(__dirname, '../../dist'), | |
filename: '[name]-bundle.js', | |
publicPath: '/', | |
}, | |
module: { | |
rules: [ | |
// JS & JSX | |
{ | |
test: /\.(js|jsx)$/, | |
exclude: /node_modules/, | |
use: ['babel-loader', 'eslint-loader'], | |
}, | |
// HTML | |
{ | |
test: /\.html$/, | |
use: [ | |
{ | |
loader: 'html-loader', | |
options: { | |
minimize: false, | |
}, | |
}, | |
], | |
}, | |
// BMP, GIF, JPEG, PNG | |
{ | |
test: [/\.bmp$/, /\.gif$/, /\.jpe?g$/, /\.png$/], | |
loader: 'url-loader', | |
options: { | |
limit: 10000, | |
name: 'static/media/[name].[hash:8].[ext]', | |
}, | |
}, | |
// CSS | |
{ | |
test: /\.css$/, | |
use: [ | |
{ | |
loader: 'style-loader', | |
}, | |
{ | |
loader: 'css-loader', | |
options: { | |
importLoaders: 1, | |
modules: true, | |
localIdentName: '[name]__[local]__[hash:base64:5]', | |
}, | |
}, | |
], | |
}, | |
// SCSS | |
{ | |
test: /\.scss$/, | |
use: [ | |
{ | |
loader: 'style-loader', | |
}, | |
{ | |
loader: 'css-loader', | |
options: { | |
importLoaders: 1, | |
modules: true, | |
localIdentName: '[name]__[local]__[hash:base64:5]', | |
}, | |
}, | |
{ | |
loader: 'sass-loader', | |
}, | |
], | |
}, | |
], | |
}, | |
resolve: { | |
extensions: ['*', '.js', '.jsx'], | |
}, | |
plugins: [ | |
new HtmlWebPackPlugin({ | |
template: './public/index.html', | |
filename: './index.html', | |
}), | |
new webpack.HotModuleReplacementPlugin(), | |
new ErrorOverlayPlugin(), | |
], | |
devServer: { | |
stats: 'errors-only', | |
host: process.env.HOST, | |
port: 8888, | |
open: true, | |
overlay: true, | |
contentBase: './public', | |
historyApiFallback: true, | |
hot: true, | |
}, | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment