Skip to content

Commit

Permalink
build(composer): Add script to copy files required by TCPDF
Browse files Browse the repository at this point in the history
  • Loading branch information
Sidsector9 committed Aug 2, 2018
1 parent ac2eed0 commit 0e5ab29
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 61 deletions.
8 changes: 6 additions & 2 deletions composer.json
Expand Up @@ -23,10 +23,14 @@
},
"scripts": {
"post-install-cmd": [
"\"vendor/bin/phpcs\" --config-set installed_paths vendor/wp-coding-standards/wpcs"
"[ -f vendor/bin/phpcs ] && \"vendor/bin/phpcs\" --config-set installed_paths vendor/wp-coding-standards/wpcs || true",
"rm -rf ./vendor/tecnickcom/tcpdf/fonts/*",
"cp ./assets/src/tcpdf-fonts/* ./vendor/tecnickcom/tcpdf/fonts/"
],
"post-update-cmd": [
"\"vendor/bin/phpcs\" --config-set installed_paths vendor/wp-coding-standards/wpcs"
"[ -f vendor/bin/phpcs ] && \"vendor/bin/phpcs\" --config-set installed_paths vendor/wp-coding-standards/wpcs || true",
"rm -rf ./vendor/tecnickcom/tcpdf/fonts/*",
"cp ./assets/src/tcpdf-fonts/* ./vendor/tecnickcom/tcpdf/fonts/"
]
}
}
61 changes: 2 additions & 59 deletions webpack.config.js
Expand Up @@ -167,69 +167,12 @@ if ( inProduction ) {
team: 'WordImpress <info@wordimpress.com>'
} );

/**
* Files to delete/preserve to optimize the size of
* TCPDF library included under vendor/ folder.
*/
$composerTcpdf = new CleanWebpackPlugin(
[ 'vendor/tecnickcom/tcpdf/fonts' ],
{
root: __dirname,
// dry: true, // Uncomment to make a dry run to see what files are deleted.
verbose: true,
exclude: [
'CODE2000.TTF',
'code2000.ctg.z',
'code2000.php',
'code2000.z',
'code2000.z.cpgz',
'dejavusans.php',
'dejavusans.z',
'dejavusans.ctg.z',
'helvetica.php',
'pdfahelvetica.php',
'pdfahelvetica.z',
],
}
);

/**
* Files to delete/preserve to optimize the size of
* TCPDF library included under libraries/ folder.
*/
$giveTcpdf = new CleanWebpackPlugin(
[ 'includes/libraries/tcpdf/fonts' ],
{
root: __dirname,
// dry: true, // Uncomment to make a dry run to see what files are deleted.
verbose: true,
exclude: [
'CODE2000.TTF',
'code2000.ctg.z',
'code2000.php',
'code2000.z',
'code2000.z.cpgz',
'dejavusans.ctg.z',
'dejavusans.php',
'dejavusans.z',
'helvetica.php',
'helveticab.php',
'helveticabi.php',
'helveticai.php',
],
}
);

// Uglify JS.
config.plugins.push( new webpack.optimize.UglifyJsPlugin( { sourceMap: true } ) );

// Minify CSS.
config.plugins.push( new webpack.LoaderOptionsPlugin( { minimize: true } ) );

// Delete unneccesary fonts for TCPDF (composer version).
config.plugins.push( $composerTcpdf );

// Delete unneccesary fonts for TCPDF (Give version).
config.plugins.push( $giveTcpdf );

// Delete fonts related to TCPDF.
config.plugins.push( new CleanWebpackPlugin( ['assets/src/tcpdf-fonts'] ) );
}

0 comments on commit 0e5ab29

Please sign in to comment.