Skip to content

Instantly share code, notes, and snippets.

@Twiggeh
Created November 29, 2020 17:28
Show Gist options
  • Save Twiggeh/057a8f8e03a0d7ffbd3d4eb2e9dd4f24 to your computer and use it in GitHub Desktop.
Save Twiggeh/057a8f8e03a0d7ffbd3d4eb2e9dd4f24 to your computer and use it in GitHub Desktop.
Bug Report
const path = require('path');
const process = require('process');
require('dotenv').config();
const mode = process.env.NODE_ENV;
const HtmlWebpackPlugin = require('html-webpack-plugin');
const ESLintPlugin = require('eslint-webpack-plugin');
const webpack = require('webpack');
console.log(mode);
const curProcess = process.cwd();
module.exports = {
entry: ['react-hot-loader/patch', path.resolve(curProcess, 'src')],
devtool: 'source-map',
devServer: {
contentBase: path.resolve(curProcess, 'src/'),
historyApiFallback: true,
hot: true,
compress: true,
},
mode: 'development',
module: {
rules: [
{
test: /\.(js|jsx)$/,
exclude: /node_modules/,
loader: 'babel-loader',
options: {
presets: ['@babel/preset-react'],
// don't inject babel code into each file, create a global import for them
plugins: ['@babel/plugin-transform-runtime'],
compact: false,
cacheDirectory: true,
cacheCompression: false,
sourceMaps: true,
inputSourceMap: true,
},
},
{
test: /\.css?$/,
use: ['style-loader', 'css-loader'],
},
{
test: /\.(woff(2)?|ttf|eot)?$/,
use: [
{
loader: 'file-loader',
options: {
name: '[name].[ext]',
outputPath: 'public/fonts/',
},
},
],
},
{
test: /\.(jpg|jpeg|png|webp)?$/,
use: {
loader: 'file-loader',
options: {
name: '[name].[ext]',
outputPath: 'public/images/',
},
},
},
{
test: /\.gif?$/,
use: {
loader: 'file-loader',
options: {
name: '[name].[ext]',
outputPath: 'public/gif/',
},
},
},
{
test: /\.m4v?$/,
use: {
loader: 'file-loader',
options: {
name: '[name].[ext]',
outputPath: 'public/video/',
},
},
},
// {
// test: /\.html?$/,
// use: {
// loader: 'file-loader',
// options: {
// name: '[name].[ext]',
// outputPath: 'webpages',
// },
// },
// },
{
test: /\.pdf$/,
use: {
loader: 'file-loader',
options: {
name: '[name].[ext]',
outputPath: 'public/pdf/',
},
},
},
{
test: /\.svg$/,
use: [
'babel-loader',
{
loader: 'react-svg-loader',
options: {
svgo: {
plugins: [{ removeDimensions: true, removeViewBox: false }],
floatPrecision: 2,
},
},
},
],
},
],
},
resolve: {
alias: {
'react-dom': '@hot-loader/react-dom',
icons: path.resolve(curProcess, './src/assets/icons'),
assets: path.resolve(curProcess, './src/assets'),
pictures: path.resolve(curProcess, './src/static/Pictures.js'),
},
modules: ['src', 'node_modules'],
extensions: ['*', '.js', '.jsx'],
},
node: { __dirname: true, __filename: true }, // to get correct __dirname and __filename
// prettier-ignore
plugins: [
new ESLintPlugin(),
new HtmlWebpackPlugin({
template: path.resolve(curProcess, 'src/index.dev.html'),
filename: 'index.html',
}),
new webpack.DefinePlugin({
MY_VARIABLES: JSON.stringify('Must stringify a String, don\'t ask me why.'),
}),
],
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment