Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Specify webpack mode production in build script #3

Merged
merged 1 commit into from
Oct 5, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

# production
/build
/dist

# misc
.DS_Store
Expand All @@ -21,4 +22,3 @@
npm-debug.log*
yarn-debug.log*
yarn-error.log*
/dist/build
12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@
"react": "^18.2.0",
"react-bootstrap": "^2.5.0",
"react-dom": "^18.2.0",
"react-scripts": "5.0.1"
"react-scripts": "5.0.1"
},
"scripts": {
"build": "webpack --config webpack.config.js",
"scripts": {
"start": "webpack serve --config webpack.config.js",
"build": "webpack --config webpack.config.js --mode=production",
"test": "react-scripts test",
"eject": "react-scripts eject",
"start": "webpack serve --config webpack.config.js"
"eject": "react-scripts eject"
},
"eslintConfig": {
"extends": [
Expand All @@ -38,4 +38,4 @@
"webpack": "^5.74.0",
"webpack-cli": "^4.10.0"
}
}
}
81 changes: 41 additions & 40 deletions webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,45 +2,46 @@ const path = require('path');
const TerserPlugin = require('terser-webpack-plugin');
var HtmlWebpackPlugin = require('html-webpack-plugin');

module.exports = (env) => {
return {
mode: 'development',
entry: {
app: './src/index.js',
module.exports = () => {
return {
mode: 'development',
entry: {
app: './src/index.js',
},
output: {
path: path.join(__dirname, '/dist'),
filename: 'index.bundle.js',
clean: true,
},
module: {
rules: [
{
test: /\.(js|jsx)$/,
exclude: /node_modules/,
use: {
loader: 'babel-loader'
}
},
output: {
path: path.join(__dirname, '/dist/build'),
filename: 'index.bundle.js',
clean: true,
},
module: {
rules: [
{
test: /\.(js|jsx)$/,
exclude: /node_modules/,
use: {
loader: 'babel-loader'
}
},
{
test: /\.css$/,
use: ['style-loader', 'css-loader']
}
]
},
optimization: {
minimizer: [
new TerserPlugin({
parallel: true,
terserOptions: {
},
}),
]
},
plugins: [
new HtmlWebpackPlugin({
template: './public/index.html'
})
]
};
{
test: /\.css$/,
use: ['style-loader', 'css-loader']
}
]
},
optimization: {
minimize: true,
minimizer: [
new TerserPlugin({
parallel: true,
terserOptions: {
},
}),
]
},
plugins: [
new HtmlWebpackPlugin({
template: './public/index.html'
})
]
};
};