Ghost/test/utils/fixtures/themes/price-data-test-theme/gulpfile.js
Fabien 'egg' O'Carroll d19452147d
🐛 Fixed @price template data to work with price helper (#12764)
closes https://github.com/TryGhost/Team/issues/545

The price helper requires an object with amount & currency properties to
work correctly. This updates the @price data object to expose these.

In order to maintain backward compatibility with using the @price data
as primitive number values, we add a valueOf method which returns the
legacy dollar amount value.

This means you can use {{price @price.monthly}} OR
{{@price.monthly}} - the second of which will output the dollar
amount.

A new theme fixture was added to test both usages of the @price data
2021-03-18 16:13:10 +00:00

70 lines
1.8 KiB
JavaScript

const gulp = require('gulp');
// gulp plugins and utils
const gutil = require('gulp-util');
const livereload = require('gulp-livereload');
const postcss = require('gulp-postcss');
const sourcemaps = require('gulp-sourcemaps');
const zip = require('gulp-zip');
// postcss plugins
const autoprefixer = require('autoprefixer');
const colorFunction = require('postcss-color-function');
const cssnano = require('cssnano');
const customProperties = require('postcss-custom-properties');
const easyimport = require('postcss-easy-import');
const swallowError = function swallowError(error) {
gutil.log(error.toString());
gutil.beep();
this.emit('end');
};
const nodemonServerInit = function () {
livereload.listen(1234);
};
gulp.task('build', ['css'], function (/* cb */) {
return nodemonServerInit();
});
gulp.task('css', function () {
const processors = [
easyimport,
customProperties,
colorFunction(),
autoprefixer({browsers: ['last 2 versions']}),
cssnano()
];
return gulp.src('assets/css/*.css')
.on('error', swallowError)
.pipe(sourcemaps.init())
.pipe(postcss(processors))
.pipe(sourcemaps.write('.'))
.pipe(gulp.dest('assets/built/'))
.pipe(livereload());
});
gulp.task('watch', function () {
gulp.watch('assets/css/**', ['css']);
});
gulp.task('zip', ['css'], function () {
const targetDir = 'dist/';
const themeName = require('./package.json').name;
const filename = themeName + '.zip';
return gulp.src([
'**',
'!node_modules', '!node_modules/**',
'!dist', '!dist/**'
])
.pipe(zip(filename))
.pipe(gulp.dest(targetDir));
});
gulp.task('default', ['build'], function () {
gulp.start('watch');
});