function stylesDev() { return src('./src/assets/css/style.css') .pipe(plumber({ errorHandler: onError })) .pipe(sourcemaps.init()) .pipe(postcss(pluginsListDev)) .pipe(sourcemaps.write('.')) .pipe(dest('./build/wordpress/wp-content/themes/' + themeName)) .pipe(browserSync.stream({ match: '**/*.css' })); }
// export CSS properties into a JavaScript file, so whoever uses it doesn't need to parse CSS over and over postcss( [ postcssCustomProperties( { importFrom: OUTPUT_FILE, exportTo: [ OUTPUT_JS_FILE ], } ), ] ) .process( output.css, { from: INPUT_FILE } ) .catch( ( e ) => { // eslint-disable-next-line no-console console.error( 'calypso-color-schemes', e ); } );
test('@taskr/postcss (plugins)', t => { t.plan(2); create({ *foo(f) { const tmp = tmpDir('tmp-1'); yield f.source(`${dir}/*.css`).postcss({ plugins: [require('autoprefixer')] }).target(tmp); const arr = yield f.$.expand(`${tmp}/*.*`); t.equal(arr.length, 1, 'write one file to target'); const str = yield f.$.read(`${tmp}/foo.css`, 'utf8'); t.true(/-webkit-box/.test(str), 'applies `autoprefixer` plugin transform'); yield f.clear(tmp); } }).start('foo'); });
function stylesProd() { return src('./src/assets/css/style.css') .pipe(plumber({ errorHandler: onError })) .pipe(postcss(pluginsListProd)) .pipe(dest('./dist/themes/' + themeName)); }
test('@taskr/postcss (options)', t => { t.plan(4); create({ *foo(f) { const tmp = tmpDir('tmp-2'); const parser = require('postcss-scss'); yield f.source(`${dir}/*.scss`).postcss({ plugins: [ require('autoprefixer') ], options: { parser } }).target(tmp); const arr = yield f.$.expand(`${tmp}/*.*`); t.equal(arr.length, 1, 'write one file to target'); const str = yield f.$.read(`${tmp}/bar.scss`, 'utf8'); t.true(str.indexOf('-ms-flexbox') !== -1, 'applies prefixer to CSS lookalike'); t.true(str.indexOf('-webkit-box-flex: val') !== -1, 'applies prefixer to SCSS mixin'); t.ok(str, 'retains `.scss` file extension'); yield f.clear(tmp); } }).start('foo'); });
test('@taskr/postcss (package.json)', t => { t.plan(2); const taskr = new Taskr({ plugins, cwd: join(dir, 'sub2'), tasks: { *foo(f) { const tmp = tmpDir('tmp-4'); yield f.source(`${dir}/*.css`).postcss().target(tmp); const arr = yield f.$.expand(`${tmp}/*.*`); t.equal(arr.length, 1, 'write one file to target'); const str = yield f.$.read(`${tmp}/foo.css`, 'utf8'); t.true(/-webkit-box/.test(str), 'applies `autoprefixer` plugin transform'); yield f.clear(tmp); } } }); taskr.start('foo'); });
test('@taskr/postcss (plugins<Array> + options<String>)', t => { t.plan(4); const taskr = new Taskr({ plugins, cwd: join(dir, 'sub5'), tasks: { *foo(f) { const tmp = tmpDir('tmp-7'); yield f.source(`${dir}/*.scss`).postcss().target(tmp); const arr = yield f.$.expand(`${tmp}/*.*`); t.equal(arr.length, 1, 'write one file to target'); const str = yield f.$.read(`${tmp}/bar.scss`, 'utf8'); t.true(str.indexOf('-ms-flexbox') !== -1, 'applies prefixer to CSS lookalike'); t.true(str.indexOf('-webkit-box-flex: val') !== -1, 'applies prefixer to SCSS mixin'); t.ok(str, 'retains `.scss` file extension'); yield f.clear(tmp); } } }); taskr.start('foo'); });
test('@taskr/postcss (plugins)', t => { t.plan(2); create({ *foo(f) { const tmp = tmpDir('tmp-1'); yield f.source(`${dir}/*.css`).postcss({ plugins: [require('autoprefixer')] }).target(tmp); const arr = yield f.$.expand(`${tmp}/*.*`); t.equal(arr.length, 1, 'write one file to target'); const str = yield f.$.read(`${tmp}/foo.css`, 'utf8'); t.true(/-webkit-box/.test(str), 'applies `autoprefixer` plugin transform'); yield f.clear(tmp); } }).start('foo'); });
test('@taskr/postcss (package.json)', t => { t.plan(2); const taskr = new Taskr({ plugins, cwd: join(dir, 'sub2'), tasks: { *foo(f) { const tmp = tmpDir('tmp-4'); yield f.source(`${dir}/*.css`).postcss().target(tmp); const arr = yield f.$.expand(`${tmp}/*.*`); t.equal(arr.length, 1, 'write one file to target'); const str = yield f.$.read(`${tmp}/foo.css`, 'utf8'); t.true(/-webkit-box/.test(str), 'applies `autoprefixer` plugin transform'); yield f.clear(tmp); } } }); taskr.start('foo'); });
test('@taskr/postcss (postcssrc)', t => { t.plan(2); const taskr = new Taskr({ plugins, cwd: join(dir, 'sub1'), tasks: { *foo(f) { const tmp = tmpDir('tmp-3'); yield f.source(`${dir}/*.css`).postcss().target(tmp); const arr = yield f.$.expand(`${tmp}/*.*`); t.equal(arr.length, 1, 'write one file to target'); const str = yield f.$.read(`${tmp}/foo.css`, 'utf8'); t.true(/-webkit-box/.test(str), 'applies `autoprefixer` plugin transform'); yield f.clear(tmp); } } }); taskr.start('foo'); });
test('@taskr/postcss (plugins<Array> + options<String>)', t => { t.plan(4); const taskr = new Taskr({ plugins, cwd: join(dir, 'sub5'), tasks: { *foo(f) { const tmp = tmpDir('tmp-7'); yield f.source(`${dir}/*.scss`).postcss().target(tmp); const arr = yield f.$.expand(`${tmp}/*.*`); t.equal(arr.length, 1, 'write one file to target'); const str = yield f.$.read(`${tmp}/bar.scss`, 'utf8'); t.true(str.indexOf('-ms-flexbox') !== -1, 'applies prefixer to CSS lookalike'); t.true(str.indexOf('-webkit-box-flex: val') !== -1, 'applies prefixer to SCSS mixin'); t.ok(str, 'retains `.scss` file extension'); yield f.clear(tmp); } } }); taskr.start('foo'); });
test('@taskr/postcss (postcss.config.js)', t => { t.plan(2); const taskr = new Taskr({ plugins, cwd: join(dir, 'sub3'), tasks: { *foo(f) { const tmp = tmpDir('tmp-5'); yield f.source(`${dir}/*.css`).postcss().target(tmp); const arr = yield f.$.expand(`${tmp}/*.*`); t.equal(arr.length, 1, 'write one file to target'); const str = yield f.$.read(`${tmp}/foo.css`, 'utf8'); t.true(/-webkit-box/.test(str), 'applies `autoprefixer` plugin transform'); yield f.clear(tmp); } } }); taskr.start('foo'); });
test('@taskr/postcss (.postcssrc.js)', t => { t.plan(2); const taskr = new Taskr({ plugins, cwd: join(dir, 'sub4'), tasks: { *foo(f) { const tmp = tmpDir('tmp-6'); yield f.source(`${dir}/*.css`).postcss().target(tmp); const arr = yield f.$.expand(`${tmp}/*.*`); t.equal(arr.length, 1, 'write one file to target'); const str = yield f.$.read(`${tmp}/foo.css`, 'utf8'); t.true(/-webkit-box/.test(str), 'applies `autoprefixer` plugin transform'); yield f.clear(tmp); } } }); taskr.start('foo'); });
test('@taskr/postcss (postcssrc)', t => { t.plan(2); const taskr = new Taskr({ plugins, cwd: join(dir, 'sub1'), tasks: { *foo(f) { const tmp = tmpDir('tmp-3'); yield f.source(`${dir}/*.css`).postcss().target(tmp); const arr = yield f.$.expand(`${tmp}/*.*`); t.equal(arr.length, 1, 'write one file to target'); const str = yield f.$.read(`${tmp}/foo.css`, 'utf8'); t.true(/-webkit-box/.test(str), 'applies `autoprefixer` plugin transform'); yield f.clear(tmp); } } }); taskr.start('foo'); });
test('@taskr/postcss (postcss.config.js)', t => { t.plan(2); const taskr = new Taskr({ plugins, cwd: join(dir, 'sub3'), tasks: { *foo(f) { const tmp = tmpDir('tmp-5'); yield f.source(`${dir}/*.css`).postcss().target(tmp); const arr = yield f.$.expand(`${tmp}/*.*`); t.equal(arr.length, 1, 'write one file to target'); const str = yield f.$.read(`${tmp}/foo.css`, 'utf8'); t.true(/-webkit-box/.test(str), 'applies `autoprefixer` plugin transform'); yield f.clear(tmp); } } }); taskr.start('foo'); });