Created
January 3, 2021 13:24
-
-
Save LUN7/48d4b8a5e64646042ab5c6a507ef245e to your computer and use it in GitHub Desktop.
react webpack 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 HtmlWebPackPlugin = require('html-webpack-plugin'); | |
module.exports = { | |
context: path.resolve(__dirname,'src'), | |
entry: './index.js', | |
output: { | |
path: path.resolve(__dirname, 'dist'), | |
filename: 'main.js', | |
publicPath:'./', | |
}, | |
devServer: { | |
contentBase: path.join(__dirname,'dist'), | |
compress: true, | |
port:3000, | |
historyApiFallback: true | |
}, | |
module: { | |
rules: [ | |
{ | |
test: /\.(js|jsx)$/, | |
exclude: /node_modules/, | |
use: { | |
loader: 'babel-loader', | |
}, | |
}, | |
{ | |
test: /\.css$/, | |
use: [ | |
{ | |
loader: 'style-loader', | |
}, | |
{ | |
loader: 'css-loader', | |
}, | |
], | |
}, | |
], | |
}, | |
plugins: [ | |
new HtmlWebPackPlugin({ | |
template: path.resolve( __dirname, 'public/index.html'), | |
filename: 'index.html' | |
}), | |
], | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment