Last active
December 9, 2021 05:16
-
-
Save savayer/4a5d2ee477732008e5cada1c12b1e5b8 to your computer and use it in GitHub Desktop.
base 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
{ | |
"name": "name", | |
"version": "1.0.0", | |
"description": "", | |
"scripts": { | |
"dev": "webpack serve --config webpack.config.js --mode development", | |
"build": "webpack build --config webpack.config.js --mode production" | |
}, | |
"keywords": [], | |
"author": "", | |
"devDependencies": { | |
"@babel/preset-env": "^7.16.4", | |
"babel-loader": "^8.2.3", | |
"css-loader": "^6.5.1", | |
"html-webpack-plugin": "^5.5.0", | |
"path": "^0.12.7", | |
"style-loader": "^3.3.1", | |
"webpack": "^5.64.4", | |
"webpack-cli": "^4.9.1", | |
"webpack-dev-server": "^4.6.0" | |
} | |
} |
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'); | |
const config = { | |
entry: './src/index.js', | |
output: { | |
filename: 'index.js', | |
path: path.resolve(__dirname, 'dist') | |
}, | |
devServer: { | |
static: path.join(__dirname, 'dist'), | |
port: 9000, | |
open: true, | |
watchFiles: ['src/**/*'] | |
}, | |
devtool: 'inline-source-map', | |
module: { | |
rules: [ | |
{ | |
test: /\.css$/i, | |
use: ["style-loader", "css-loader"], | |
}, | |
{ | |
test: /\.js$/, | |
exclude: /(node_modules)/, | |
use: { | |
loader: require.resolve("babel-loader"), | |
options: { | |
presets: ['@babel/preset-env'] | |
} | |
} | |
} | |
] | |
}, | |
plugins: [ | |
new HtmlWebpackPlugin({ | |
template: 'src/index.html' | |
}) | |
] | |
} | |
module.exports = config; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment