Skip to content

Commit

Permalink
Make ready for automatic packaging directly from build script
Browse files Browse the repository at this point in the history
  • Loading branch information
svnhub committed Oct 2, 2024
1 parent 8bc8a88 commit b48e6bc
Show file tree
Hide file tree
Showing 7 changed files with 41 additions and 66 deletions.
17 changes: 17 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,20 @@
node_modules/
dist/
package-lock.json
build/content.css
build/content.js
build/editor.html
build/editor.js
build/hide.svg
build/icon_48.png
build/icon_96.png
build/logo.svg
build/main.css
build/manifest.json
build/minimize.svg
build/options.html
build/popup.html
build/service.js
build/templates.html
build/ui.css
build/ui.js
1 change: 0 additions & 1 deletion Extension/manifest.firefox.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
"default_popup": "popup.html"
},
"background": {
"service_worker": "service.js",
"scripts": [
"service.js"
]
Expand Down
56 changes: 0 additions & 56 deletions Extension/manifest.json

This file was deleted.

File renamed without changes.
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,10 @@ Lastly, if you intend to review or make changes to the code, you can build and i
git clone https://github.com/cavi-au/Consent-O-Matic.git
cd Consent-O-Matic
npm install
npm run build
```
Then proceed as above for installing release archives but point the browser at the `dist` folder.
and then run one of ```npm run build-firefox``` or ```npm run build-chromium``` or ```npm run build-safari```

For Firefox or Chromium you can now proceed as above for installing release archives but point the browser at the `build` folder or a folder where you extracted the zip from build/dist/. Safari requires loading the XCode project to further build an app.

We do not recommend installing from source.

Expand Down
8 changes: 6 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,17 @@
"url": "https://github.com/cavi-au/Consent-O-Matic"
},
"scripts": {
"build": "webpack"
"build-firefox": "webpack --env target=firefox",
"build-chromium": "webpack --env target=chromium",
"build-safari": "webpack --env target=safari"
},
"dependencies": {
"copy-webpack-plugin": "^12.0.2",
"glob": "^10.3.12",
"html-minimizer-webpack-plugin": "^5.0.0",
"sass": "^1.77.0",
"sass-loader": "^14.2.1",
"webpack-cli": "^5.1.4"
"webpack-cli": "^5.1.4",
"zip-webpack-plugin": "^4.0.1"
}
}
20 changes: 15 additions & 5 deletions webpack.config.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
const HtmlMinimizerPlugin = require("html-minimizer-webpack-plugin");
const PACKAGE = require('./package.json');
const ZipPlugin = require('zip-webpack-plugin');
const CopyPlugin = require("copy-webpack-plugin");
const path = require('path');
const glob = require("glob");
module.exports = {
module.exports = env=>({
mode: 'production',
entry: {
service: ['./Extension/background.js'],
content: [
'./Extension/contentScript.js',
"./Extension/manifest.json",
"./Extension/content.scss",
"./Extension/icon_48.png",
"./Extension/icon_96.png",
Expand All @@ -28,7 +30,7 @@ module.exports = {
output: {
publicPath: "",
filename: '[name].js',
path: path.resolve(__dirname, 'dist')
path: path.resolve(__dirname, 'build')
},
module: {
parser: {
Expand Down Expand Up @@ -63,5 +65,13 @@ module.exports = {
'...',
new HtmlMinimizerPlugin(),
],
},
}
},
plugins: [
new CopyPlugin({patterns: [{from: "Extension/manifest."+env.target+".json", to: "manifest.json",force:true }]}),
new ZipPlugin({
path: 'dist/',
filename: PACKAGE.name+"-v"+PACKAGE.version+"-unpacked-release-"+env.target+".zip",
exclude: [/^dist/]
})
]
});

0 comments on commit b48e6bc

Please sign in to comment.