Skip to content

Commit

Permalink
chore(example): build for production
Browse files Browse the repository at this point in the history
This prevents unneeded hick-ups during loading.
  • Loading branch information
nikku committed Sep 30, 2024
1 parent 9d2a6f0 commit 96ce381
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 5 deletions.
5 changes: 3 additions & 2 deletions example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
"name": "example",
"private": true,
"scripts": {
"build": "webpack",
"start": "webpack serve --open"
"build": "cross-env NODE_ENV=production webpack",
"start": "cross-env NODE_ENV=development webpack serve --open"
},
"devDependencies": {
"@babel/core": "^7.25.2",
Expand All @@ -15,6 +15,7 @@
"file-drops": "^0.5.0",
"file-open": "^0.1.1",
"html-webpack-plugin": "^5.6.0",
"mini-css-extract-plugin": "^2.9.1",
"raw-loader": "^4.0.2",
"style-loader": "^4.0.0",
"webpack": "^5.94.0",
Expand Down
16 changes: 13 additions & 3 deletions example/webpack.config.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@

const path = require('path');

const MiniCssExtractPlugin = require("mini-css-extract-plugin");

const HtmlWebpackPlugin = require('html-webpack-plugin');

module.exports = {
mode: 'development',
entry: {
app: path.resolve(__dirname, './src/app.js'),
},
Expand All @@ -26,15 +27,24 @@ module.exports = {
},
{
test: /\.css$/i,
use: [ 'style-loader', 'css-loader' ],
use: [
process.env.NODE_ENV !== "production"
? "style-loader"
: MiniCssExtractPlugin.loader,
'css-loader'
],
}
]
},
plugins: [
new HtmlWebpackPlugin({
template: './src/index.html',
})
],
].concat(
process.env.NODE_ENV !== "production"
? []
: new MiniCssExtractPlugin()
),
devtool: 'eval-source-map',
devServer: {
hot: false,
Expand Down
32 changes: 32 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 96ce381

Please sign in to comment.