Skip to content

Commit

Permalink
No issue - fixed production builds (#152)
Browse files Browse the repository at this point in the history
  • Loading branch information
Manvel authored Mar 31, 2024
1 parent 728e99f commit abd8bd4
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"build": "npm run clean && npm run build:webpack:prod && cd dist/;zip -r ../cba.zip .;cd ..",
"build:webpack": "npm run clean && npm run import:components && webpack --config webpack.config.js",
"build:webpack:watch": "npm run clean && npm run import:components && webpack --config webpack.config.js --watch",
"build:webpack:prod": "npm run clean && npm run import:components && webpack --config webpack.config.js --prod",
"build:webpack:prod": "npm run clean && npm run import:components && PROD=1 webpack --config webpack.config.js",
"clean": "rm -r dist || true"
},
"repository": {
Expand Down
12 changes: 9 additions & 3 deletions webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,16 @@ const CopyPlugin = require('copy-webpack-plugin');
const {minify} = require("csso");
const {extname} = require("path");

/**
* @param {Buffer} content
* @param {string} file
*/
const transformCss = (content, file) =>
{
if (argv.prod && extname(file) === ".css")
return minify(content).css;
if (process.env.PROD && extname(file) === ".css") {
const res = minify(content.toString());
return res.css;
}
else
return content;
}
Expand Down Expand Up @@ -68,7 +74,7 @@ if (argv.watch)
module.exports.watch = true;
}

if (argv.prod)
if (process.env.PROD)
{
module.exports.mode = "production";
module.exports.optimization.minimize = true;
Expand Down

0 comments on commit abd8bd4

Please sign in to comment.