This repository has been archived by the owner on Sep 10, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 144
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #19 from keraf/build
Added build step.
- Loading branch information
Showing
13 changed files
with
146 additions
and
5 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
dist/* | ||
certs/* | ||
node_modules/* |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
const fs = require('fs'); | ||
const gulp = require('gulp'); | ||
const babel = require('gulp-babel'); | ||
const uglify = require('gulp-uglify'); | ||
const cleanCSS = require('gulp-clean-css'); | ||
const jeditor = require('gulp-json-editor'); | ||
const crx = require('gulp-crx-pack'); | ||
const zip = require('gulp-zip'); | ||
const del = require('del'); | ||
const runSequence = require('run-sequence'); | ||
|
||
const package = JSON.parse(fs.readFileSync('./package.json')); | ||
const srcFolder = './src'; | ||
const buildFolder = './dist/tmp'; | ||
const babelConfig = { | ||
presets: ['env'], | ||
plugins: ['transform-object-rest-spread'], | ||
} | ||
|
||
// Clean old files | ||
gulp.task('build:clean', () => { | ||
return del(`${buildFolder}/**/*`); | ||
}); | ||
|
||
// Copy files to build folder | ||
gulp.task('build:copy', () => { | ||
return gulp.src([ | ||
`${srcFolder}/**/*`, | ||
`!${srcFolder}/**/*.js`, | ||
`!${srcFolder}/**/*.css`, | ||
`!${srcFolder}/manifest.json`]) | ||
.pipe(gulp.dest(buildFolder)); | ||
}); | ||
|
||
// Transform the manifest | ||
gulp.task('build:manifest', () => { | ||
return gulp.src(`${srcFolder}/manifest.json`) | ||
.pipe(jeditor({ | ||
'version': package.version, | ||
})) | ||
.pipe(gulp.dest(buildFolder)); | ||
}); | ||
|
||
// Transform the JS files | ||
gulp.task('build:js', () => { | ||
gulp.src([`${srcFolder}/js/background.js`, `${srcFolder}/js/popup.js`]) | ||
.pipe(babel(babelConfig)) | ||
.pipe(uglify()) | ||
.pipe(gulp.dest(`${buildFolder}/js`)); | ||
|
||
return gulp.src(`${srcFolder}/js/jquery.min.js`) | ||
.pipe(gulp.dest(`${buildFolder}/js`)); | ||
}); | ||
|
||
// Transform the CSS file | ||
gulp.task('build:css', () => { | ||
return gulp.src(`${srcFolder}/styles/popup.css`) | ||
.pipe(cleanCSS()) | ||
.pipe(gulp.dest(`${buildFolder}/styles`)); | ||
}); | ||
|
||
// Zip it for FF | ||
gulp.task('pack:firefox', () => { | ||
return gulp.src(`${buildFolder}/**/*`) | ||
.pipe(zip(`nocoin-${package.version}.xpi`)) | ||
.pipe(gulp.dest('./dist/firefox')); | ||
}); | ||
|
||
// Zip it for Chrome | ||
gulp.task('pack:chrome', () => { | ||
return gulp.src(`${buildFolder}/**/*`) | ||
.pipe(zip(`nocoin-${package.version}.zip`)) | ||
.pipe(gulp.dest('./dist/chrome')); | ||
}); | ||
|
||
// Make CRX | ||
gulp.task('pack:chromium', () => { | ||
return gulp.src(`${buildFolder}`) | ||
.pipe(crx({ | ||
privateKey: fs.readFileSync('./certs/key.pem', 'utf8'), | ||
filename: `nocoin-${package.version}.crx`, | ||
codebase: 'https://nocoin.ker.af/', | ||
updateXmlFilename: 'update.xml' | ||
})) | ||
.pipe(gulp.dest('./dist/chromium')); | ||
}); | ||
|
||
gulp.task('default', () => { | ||
runSequence( | ||
'build:clean', | ||
'build:copy', | ||
[ | ||
'build:manifest', | ||
'build:js', | ||
'build:css', | ||
], | ||
[ | ||
'pack:firefox', | ||
'pack:chrome', | ||
'pack:chromium', | ||
] | ||
); | ||
}); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
{ | ||
"name": "no-coin", | ||
"version": "0.3.1", | ||
"description": "Stop coin miners on the web!", | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/keraf/NoCoin.git" | ||
}, | ||
"author": "Rafael Keramidas", | ||
"license": "MIT", | ||
"bugs": { | ||
"url": "https://github.com/keraf/NoCoin/issues" | ||
}, | ||
"homepage": "https://github.com/keraf/NoCoin#readme", | ||
"devDependencies": { | ||
"babel-core": "^6.26.0", | ||
"babel-plugin-transform-object-rest-spread": "^6.26.0", | ||
"babel-preset-env": "^1.6.0", | ||
"del": "^3.0.0", | ||
"gulp": "^3.9.1", | ||
"gulp-babel": "^7.0.0", | ||
"gulp-clean-css": "^3.9.0", | ||
"gulp-crx-pack": "^1.0.1", | ||
"gulp-json-editor": "^2.2.1", | ||
"gulp-uglify": "^3.0.0", | ||
"gulp-zip": "^4.0.0", | ||
"run-sequence": "^2.2.0" | ||
} | ||
} |
File renamed without changes.
File renamed without changes
File renamed without changes
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
File renamed without changes.
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
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
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
Large diffs are not rendered by default.
Oops, something went wrong.
File renamed without changes.