Skip to content

Instantly share code, notes, and snippets.

@chetanyakan
Last active July 6, 2020 15:35
Show Gist options
  • Save chetanyakan/b0e63b2819fb13499a3169e941100501 to your computer and use it in GitHub Desktop.
Save chetanyakan/b0e63b2819fb13499a3169e941100501 to your computer and use it in GitHub Desktop.
Webpack + Static file server
import React from 'react';
import loadingGif from 'assets/load.gif';
export default function Loader() {
return (
<div className='loading'>
<img
alt={'Loading'}
src={loadingGif}
/>
</div>
);
}
const path = require('path');
module.exports = {
entry: [
'./src/index.jsx',
],
resolve: {
alias: {
assets: path.resolve(__dirname, '../assets'),
},
modules: [
path.resolve(__dirname, 'src'),
'node_modules',
],
extensions: ['*', '.js', '.jsx', '.json', '.scss'],
},
module: {
rules: [
// Other rules...
{
test: /.(bmp|gif|jpe?g|png|svg)$/,
exclude: /node_modules/,
use: [
{
loader: 'file-loader',
options: {
// For assets, only emit the file URL
// as the static files are served from the server.
emitFile: false,
name: '[name].[ext]',
publicPath: '/static/',
},
},
],
},
],
},
output: {
path: path.join(__dirname, '/dist'),
publicPath: '/',
filename: 'main.js',
},
devtool: 'source-map',
performance: {
hints: 'warning',
},
target: 'web',
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment