Skip to content

Commit

Permalink
Merge pull request #35 from ofuton/develop
Browse files Browse the repository at this point in the history
Release 1.1.0 🎉
  • Loading branch information
emiksk committed Feb 12, 2019
2 parents 1cdc1c0 + 6d8d075 commit f918c73
Show file tree
Hide file tree
Showing 56 changed files with 3,908 additions and 2,638 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
.idea/
node_modules/
dist/
*.zip
*.zip
src/js/templates/*.js
.DS_Store
Binary file modified figs/branding_images/screen_shot_1280x800.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
81 changes: 52 additions & 29 deletions gulpfile.js
Original file line number Diff line number Diff line change
@@ -1,31 +1,62 @@
const gulp = require('gulp');
const plumber = require('gulp-plumber');
const notify = require('gulp-notify');
const path = require('path');

const src = path.resolve(__dirname, 'src');
const scripts = path.resolve(src, 'js');

gulp.task('watch', () => {
gulp.watch('./src/scripts/**/*.js', gulp.task('scripts'));
gulp.watch('./src/html/client/**/*.pug', gulp.task('scripts'));
gulp.watch('./src/js/**/*.js', gulp.task('js'));
gulp.watch('./src/styles/**/*.css', gulp.task('styles'));
gulp.watch('./src/html/**/*.pug', gulp.task('html'));
gulp.watch('./src/html/client/**/*.pug', gulp.task('pug:client'));

// static files
gulp.watch('./src/images/**', gulp.task('images'));
gulp.watch('./src/vendors/**', gulp.task('vendors'));
gulp.watch('./src/manifest.json', gulp.task('manifest'));
});

gulp.task('scripts', () => {
const minify = require('gulp-minify');
return gulp.src('./src/scripts/**/*.js')
.pipe(minify({
ext:{
min:'.min.js'
},
noSource: true
}))
gulp.task('pug:client', (done) => {
const exec = require('child_process').exec;
exec('node ./scripts/pug-compile-client.js', (stdout, stderr) => {
console.log(stderr);
done();
});
});

gulp.task('js', () => {
const webpackStream = require('webpack-stream');
const webpack = require('webpack');
const webpackConfig = {
// FIXME: watch で実行した際は mode を development にできると良い
mode: 'production',
entry: {
content: path.join(scripts, 'content'),
background: path.join(scripts, 'background'),
popup: path.join(scripts, 'popup'),
inject: path.join(scripts, 'inject'),
},
output: {
filename: '[name].js'
},
resolve: {
extensions: [ '.js' ],
modules: [ scripts, 'node_modules' ]
},
};

return webpackStream(webpackConfig, webpack)
.pipe(gulp.dest('./dist/assets/js'));
});

gulp.task('scripts',
gulp.series(
'pug:client',
'js'
)
);

gulp.task('styles', () => {
const postcss = require('gulp-postcss');
const sourcemaps = require('gulp-sourcemaps');
Expand Down Expand Up @@ -54,8 +85,7 @@ gulp.task('html', () => {
const pug = require('gulp-pug');
return gulp.src([
'./src/html/**/*.pug',
'!./src/html/**/_*.pug',
'!./src/html/**/_client_*.pug'
'!./src/html/**/_*.pug'
])
.pipe(plumber({
errorHandler: notify.onError("Error: <%= error.message %>")
Expand All @@ -66,30 +96,23 @@ gulp.task('html', () => {
.pipe(gulp.dest('./dist/assets/html'));
});

gulp.task('pug:client', (done) => {
const exec = require('child_process').exec;
exec('node ./src/scripts/pug-compile-client.js', (stdout, stderr) => {
done();
});
});

gulp.task('images', () => {
const imagemin = require('gulp-imagemin');
return gulp.src('./src/images/**')
.pipe(imagemin())
.pipe(gulp.dest('./dist/assets/images'))
});

gulp.task('vendors', () => {
return gulp.src('./src/vendors/**')
.pipe(gulp.dest('./dist/assets/vendors'));
});

gulp.task('manifest', () => {
return gulp.src('./src/manifest.json')
.pipe( gulp.dest('./dist'));
});

gulp.task('clean:templates', () => {
const del = require('del');
return del('./src/js/templates/*.js', { force:true });
});

gulp.task('clean:dist', () => {
const del = require('del');
return del('./dist', { force:true });
Expand All @@ -102,6 +125,7 @@ gulp.task('clean:zip', () => {

gulp.task('clean:all',
gulp.parallel(
'clean:templates',
'clean:dist',
'clean:zip'
)
Expand All @@ -116,14 +140,13 @@ gulp.task('zip', () => {

gulp.task('build',
gulp.series(
'clean:templates',
'clean:dist',
gulp.parallel(
'scripts',
'styles',
'html',
'pug:client',
'images',
'vendors',
'manifest'
)
)
Expand All @@ -134,4 +157,4 @@ gulp.task('deploy',
'clean:zip',
'zip'
)
);
);
Loading

0 comments on commit f918c73

Please sign in to comment.