Last active
July 6, 2020 15:35
-
-
Save chetanyakan/b0e63b2819fb13499a3169e941100501 to your computer and use it in GitHub Desktop.
Webpack + Static file server
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
import React from 'react'; | |
import loadingGif from 'assets/load.gif'; | |
export default function Loader() { | |
return ( | |
<div className='loading'> | |
<img | |
alt={'Loading'} | |
src={loadingGif} | |
/> | |
</div> | |
); | |
} |
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'); | |
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