When working on your local workstation, running a local instance of your website is very helpful. I often create two scripts to move code from my development workspace into the local website instance. One takes the war file outputted by Maven and publishes it. The second takes all of my static content and publishes it bypassing Maven, which is much faster than building and deploying the war file.
When integrating CSS preprocessors into the workflow, I need to make sure they run in both deployment scripts. Here are the requirements for running CSS preprpceasors in my build process:
First I need to install LESS. I am running Ubuntu, so I can simply use the package manager to grab a copy. This is described in several other places already, so I'm not going to go through the process here. Check Tilap TechBlog for an overview.
Now that it's installed, I write a short script to take the CSS files and apply LESS to them. In my case I am also applying the YUI compression that is built into LESS. You'd need to change some of the paths and names in the script for your project. My less files all roll up into "transit.less" so it's the only one I need to explicitly expand.
Now we can call it from Maven using the execution plugin.
Finally, the script needs to be wired in with my static deployment script. In my case, the static deployment is a shell script similar to the script used to call the LESS processor.
So now both of my deployment workflows use the same CSS preprocessors and render identical CSS. Note the shell scripts do tie me to Linux workstations or Cygwin, which is not a big problem for me since all of my development systems are running Ubuntu.
When integrating CSS preprocessors into the workflow, I need to make sure they run in both deployment scripts. Here are the requirements for running CSS preprpceasors in my build process:
- The preprocessors need to run as part of the Maven build so my compiled files make it into the war file.
- The preproceasors should be run when I deploy just the static resources to my local instance.
First I need to install LESS. I am running Ubuntu, so I can simply use the package manager to grab a copy. This is described in several other places already, so I'm not going to go through the process here. Check Tilap TechBlog for an overview.
Now that it's installed, I write a short script to take the CSS files and apply LESS to them. In my case I am also applying the YUI compression that is built into LESS. You'd need to change some of the paths and names in the script for your project. My less files all roll up into "transit.less" so it's the only one I need to explicitly expand.
Now we can call it from Maven using the execution plugin.
Finally, the script needs to be wired in with my static deployment script. In my case, the static deployment is a shell script similar to the script used to call the LESS processor.
So now both of my deployment workflows use the same CSS preprocessors and render identical CSS. Note the shell scripts do tie me to Linux workstations or Cygwin, which is not a big problem for me since all of my development systems are running Ubuntu.
Comments
Post a Comment