Intro
When developing a gulp.js project, it is typical to have the following directory structure
PROJECT_NAME
|
---------- dist <------------ contains library to be released
|
---------- src <------------- contains all source code file
And the coding flow is
- Create source files in the
src
directory - Once the files in
src
work as designed, the project is "uglified" and "minimized", then copied to thedist
directory. - Once the
dist
directory has the final project, it is released.
So, the released version of the library is taken from the dist
directory.
Setup for WordPress
Now, onto WordPress. I typically set my development environment as follows
WORDPRESS_ROOT_DIRECTORY
|
wp-content
|
plugins
|
my_plugin
|
-------- css <---------- contains all CSS files
|
-------- inc <---------- contains all PHP files
|
-------- js <---------- contains all JavaScript files
|
-------- vendors <------- contains all libraries from other vendors
|
-------- my_plugin.php <---- this is the initial plugin file
This setup for WordPress would be OK and I have been developing plugins for it without a problem. I would develop, test, and then release.
The Issue
In my current WordPress project, I am developing a plugin that would require I minimize and uglify every file in the directory (the reasons for that are long, and I am not going into the business cases; it is a requirement). Typically I would like to create the following directory structure.
WORDPRESS_ROOT_DIRECTORY
|
wp-content
|
plugins
|
my_plugin
|
-------- dist <------ contains all minimized and uglified files
|
-------- src
|
-------- css <---------- contains all CSS files
|
-------- inc <---------- contains all PHP files
|
-------- js <---------- contains all JavaScript files
|
-------- vendors <------- contains all libraries from other vendors
|
-------- my_plugin.php <---- this is the initial plugin file
Then, the ideal flow of development would be
- Develop in the
src
directory - Once satified, minimize/uglify all PHP, CSS, and JS files into
dist
- Release the plugin from the
dist
directory
I have the following problems
I do not know if I can make such setup work. The problem is I will have functions that have the same name (referenced from
my_plugin.php
located insrc
and the minimized 'my_plugin.php' located indist
), and this would cause a WordPress function name conflict error.Can I place my root plugin file,
my_plugin.php
, in a sub/sub directory?I am not sure what tools I can use to take my files from
src
and convert them todist
while minimizing/uglifying them. I could use gulp.js to do that for my JS and CSS files, but I am not sure about PHP files. I need one tool that does that for all files.
If I am unable to create the structure above. How can I minimize/uglify ALL my files for my plugin before releasing the plugin? (And by ALL files, I mean PHP, CSS, and JS).
Thanks.