Skip to content

Commit

Permalink
recreate build process
Browse files Browse the repository at this point in the history
  • Loading branch information
Jenna Hines committed Oct 28, 2022
1 parent 4b97338 commit 4b50b50
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 19 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,7 @@ compass_app_log.txt
vendor/
build/
dist/

# tailwind config files
/fallbackPreset.js
/env.json
3 changes: 3 additions & 0 deletions env-example.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"tailwindPreset": "/Users/yourusername/Sites/yourproject/app/public/wp-content/themes/your-wd_s-theme/wds.preset.js"
}
35 changes: 16 additions & 19 deletions postcss.config.js
Original file line number Diff line number Diff line change
@@ -1,27 +1,24 @@
require( 'dotenv' ).config();

//THIS DOES NOT WORK
const fs = require( 'fs' );
const globalThemePreset = fs.existsSync( process.env.activePreset )
? process.env.activePreset
: process.env.fallbackPreset;

//THIS WORKS
// const globalThemePreset = '/Users/jennahines/Sites/wds-acf-blocks/app/public/wp-content/themes/wd_s/wds.preset.js';
const path = require( 'path' );
const request = require( 'request' );
const themeUrl =
'https://raw.githubusercontent.com/WebDevStudios/wd_s/main/wds.preset.js';
const downloadPath = path.join( path.resolve( __dirname ), './fallbackPreset.js' );

//THIS WORKS
// const path = require( 'path' );
// global.appRoot = path.resolve( __dirname );
// const globalThemePreset = path.join(
// global.appRoot,
// './../../themes/wd_s/wds.preset.js'
// );
let { tailwindPreset } = require( './env.json' );

// console.log( globalThemePreset );
if ( ! fs.existsSync( tailwindPreset ) ) {
if ( ! fs.existsSync( downloadPath ) ) {
request( themeUrl )
.pipe( fs.createWriteStream( downloadPath ) )
.on( 'close', function () {} );
}
tailwindPreset = downloadPath;
}

module.exports = {
plugins: {
tailwindcss: { config: require( globalThemePreset ) },
tailwindcss: { config: require( tailwindPreset ) },
autoprefixer: { grid: true },
...( process.env.NODE_ENV === 'production'
? {
Expand All @@ -38,5 +35,5 @@ module.exports = {
}
: {} ),
},
globalThemePreset,
tailwindPreset,
};

0 comments on commit 4b50b50

Please sign in to comment.