Skip to content

Commit e47748e

Browse files
Joe McCannclaude
authored andcommitted
Update build process and add new features
🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
1 parent 73e4076 commit e47748e

File tree

24 files changed

+37908
-182
lines changed

24 files changed

+37908
-182
lines changed

.babelrc

Lines changed: 0 additions & 9 deletions
This file was deleted.

app.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,11 @@ app.use(netjet({
9191
}))
9292

9393
// We do need this in any environment that is not Now/Zeit
94-
app.use(serveStatic(path.join(__dirname, '/public')))
94+
app.use(express.static(path.join(__dirname, 'public')))
95+
app.use('/dist', express.static(path.join(__dirname, 'public/dist')))
96+
97+
// Add this line to serve node_modules/brace/theme directly
98+
app.use('/theme-github.js', express.static(path.join(__dirname, 'node_modules/brace/theme/github.js')))
9599

96100
// Setup local variables to be available in the views.
97101
app.locals.title = config.title || 'Dillinger.'

config.js

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,25 @@
11
'use strict'
22
const rc = require('rc')
3+
34
const defaultConfig = {
45
title: 'Online Markdown Editor - Dillinger, the Last Markdown Editor ever.',
56
description: `Dillinger is an online cloud based HTML5 filled
67
Markdown Editor. Sync with Dropbox, Github, Google Drive or OneDrive.
78
Convert HTML to Markdown. 100% Open Source!`,
89
googleWebmasterMeta: 'DAyGOgtsg8rJpq9VVktKzDkQ1UhXm1FYl8SD47hPkjA',
910
keywords: 'Markdown, Dillinger, Editor, ACE, Github, Open Source, Node.js',
10-
author: 'Joe McCann and Martin Broder'
11+
author: 'Joe McCann and Martin Broder',
12+
// Add default database configuration
13+
development: {
14+
port: process.env.PORT || 8080,
15+
db: {
16+
mongodb: process.env.MONGODB_URI || 'mongodb://localhost:27017/dillinger',
17+
redis: process.env.REDIS_URL || 'redis://localhost:6379'
18+
}
19+
}
1120
}
1221

13-
module.exports = function () {
22+
// Export a function that returns the configuration
23+
module.exports = function() {
1424
return rc('dillinger', defaultConfig)
1525
}

gulp/index.js

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,24 @@
1-
21
'use strict'
32

3+
const gulp = require('gulp')
44
const fs = require('fs')
5+
const path = require('path')
56
const argv = require('yargs').argv
67
const onlyScripts = require('./util/scriptFilter')
7-
const tasks = fs.readdirSync('./gulp/tasks/').filter(onlyScripts)
88

99
global.isProduction = !!(argv.production || argv.prod)
1010

11-
tasks.forEach(function (task) {
12-
require('./tasks/' + task)
11+
// Load all tasks
12+
const tasks = fs.readdirSync('./gulp/tasks/')
13+
.filter(filename => filename.match(/\.js$/))
14+
.map(filename => path.parse(filename).name)
15+
16+
tasks.forEach(task => {
17+
const taskModule = require('./tasks/' + task)
18+
if (typeof taskModule === 'function') {
19+
gulp.task(task, taskModule)
20+
}
1321
})
22+
23+
// Export the tasks
24+
module.exports = tasks

gulp/tasks/build.js

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,26 @@
1-
21
'use strict'
32

43
const gulp = require('gulp')
54

6-
const sequence = require('run-sequence')
7-
8-
const devTasks = ['webpack:dev', 'sass']
5+
// Define build task function
6+
function buildTask(cb) {
7+
// Check if we're in production mode
8+
const isProduction = global.isProduction
99

10-
const buildTasks = ['webpack:build', 'sass']
10+
// Define the sequence of tasks
11+
const buildTasks = gulp.series(
12+
'clean',
13+
gulp.parallel(
14+
'sass',
15+
isProduction ? 'webpack:build' : 'webpack:dev'
16+
)
17+
)
1118

12-
if (global.isProduction) {
13-
gulp.task('build', function () {
14-
return sequence(buildTasks)
15-
})
16-
} else {
17-
gulp.task('build', devTasks)
19+
// Run the build sequence
20+
return buildTasks(cb)
1821
}
22+
23+
// Register build task
24+
gulp.task('build', buildTask)
25+
26+
module.exports = buildTask

gulp/tasks/clean.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
'use strict'
2+
3+
const gulp = require('gulp')
4+
const rimraf = require('gulp-rimraf')
5+
6+
function cleanTask() {
7+
return gulp.src(['./public/dist/*'], { read: false })
8+
.pipe(rimraf({ force: true }))
9+
}
10+
11+
gulp.task('clean', cleanTask)
12+
13+
module.exports = cleanTask

gulp/tasks/critical.js

Lines changed: 28 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,35 @@
1-
21
'use strict'
32

3+
const gulp = require('gulp')
44
const critical = require('critical')
55

6-
const gulp = require('gulp')
6+
function criticalTask(cb) {
7+
// Skip critical CSS generation in development
8+
if (!global.isProduction) {
9+
return cb()
10+
}
711

8-
gulp.task('critical', function () {
9-
const dest = './public'
12+
const dest = './public/dist'
1013

11-
return critical.generateInline({
12-
base: dest,
13-
src: 'index.html',
14-
styleTarget: 'app.css',
15-
htmlTarget: 'index.html',
16-
width: 320,
17-
height: 480,
18-
minify: true
14+
return critical.generate({
15+
base: './public/', // Changed base directory
16+
src: 'views/index.ejs', // Changed to look for the EJS template
17+
css: ['css/app.css'], // Updated CSS path
18+
target: {
19+
css: 'dist/critical.css',
20+
html: 'dist/index.html'
21+
},
22+
width: 1300,
23+
height: 900,
24+
minify: true,
25+
ignore: ['@font-face', /url\(/] // Ignore font-face and url references
26+
}).catch(err => {
27+
console.error('Critical CSS error:', err)
28+
// Don't fail the build on critical CSS error
29+
cb()
1930
})
20-
})
31+
}
32+
33+
gulp.task('critical', criticalTask)
34+
35+
module.exports = criticalTask

gulp/tasks/default.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
1-
21
'use strict'
32

43
const gulp = require('gulp')
54

6-
gulp.task('default', ['build'])
5+
// Update to Gulp 4 task syntax
6+
function defaultTask(cb) {
7+
// Add your default task logic here
8+
cb()
9+
}
10+
11+
gulp.task('default', defaultTask)
12+
13+
module.exports = defaultTask

gulp/tasks/rev.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
'use strict'
2+
3+
const gulp = require('gulp')
4+
const rev = require('gulp-rev')
5+
6+
function revTask() {
7+
return gulp.src(['public/dist/**/*.{css,js}'])
8+
.pipe(rev())
9+
.pipe(gulp.dest('public/dist'))
10+
.pipe(rev.manifest())
11+
.pipe(gulp.dest('public/dist'))
12+
}
13+
14+
gulp.task('rev', revTask)
15+
16+
module.exports = revTask

gulp/tasks/sass.js

Lines changed: 13 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,25 @@
11
'use strict'
22

33
const gulp = require('gulp')
4-
5-
const sass = require('gulp-sass')
6-
4+
const sass = require('gulp-sass')(require('sass'))
75
const autoprefixer = require('gulp-autoprefixer')
8-
96
const cmq = require('gulp-group-css-media-queries')
10-
117
const csso = require('gulp-csso')
12-
138
const size = require('gulp-size')
14-
159
const gulpif = require('gulp-if')
16-
1710
const handleErrors = require('../util/handleErrors')
18-
1911
const browserSync = require('browser-sync')
2012

21-
gulp.task('sass', function () {
13+
function sassTask() {
2214
const dest = './public/css'
2315

2416
console.log('app sass build')
2517

2618
gulp.src('./public/scss/app.{scss,sass}')
2719
.pipe(sass({
2820
precision: 7,
29-
outputStyle: 'nested'
30-
}))
31-
.on('error', handleErrors)
21+
outputStyle: 'expanded'
22+
}).on('error', sass.logError))
3223
.pipe(autoprefixer())
3324
.pipe(gulpif(global.isProduction, cmq({
3425
log: true
@@ -38,16 +29,15 @@ gulp.task('sass', function () {
3829
.pipe(browserSync.reload({
3930
stream: true
4031
}))
41-
.pipe(size())
32+
.pipe(size({ showFiles: true }))
4233

4334
console.log('export sass build')
4435

4536
return gulp.src('./public/scss/export.{scss,sass}')
4637
.pipe(sass({
4738
precision: 7,
48-
outputStyle: 'nested'
49-
}))
50-
.on('error', handleErrors)
39+
outputStyle: 'expanded'
40+
}).on('error', sass.logError))
5141
.pipe(autoprefixer())
5242
.pipe(gulpif(global.isProduction, cmq({
5343
log: true
@@ -57,5 +47,9 @@ gulp.task('sass', function () {
5747
.pipe(browserSync.reload({
5848
stream: true
5949
}))
60-
.pipe(size())
61-
})
50+
.pipe(size({ showFiles: true }))
51+
}
52+
53+
gulp.task('sass', sassTask)
54+
55+
module.exports = sassTask

0 commit comments

Comments
 (0)