shake-minify-css (empty) → 0.1.0.0
raw patch · 5 files changed
+106/−0 lines, 5 filesdep +basedep +directorydep +filepath
Dependencies added: base, directory, filepath, hasmin, shake, text
Files
- LICENSE +11/−0
- README.md +4/−0
- cabal.project.local +2/−0
- shake-minify-css.cabal +41/−0
- src/Development/Shake/MinifyCSS.hs +48/−0
+ LICENSE view
@@ -0,0 +1,11 @@+Copyright Vanessa McHale (c) 2019++Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:++1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.++2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.++3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.++THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ README.md view
@@ -0,0 +1,4 @@+# shake-minify-css++Use this library to minify CSS with+[shake](http://hackage.haskell.org/package/shake).
+ cabal.project.local view
@@ -0,0 +1,2 @@+documentation: True+haddock-internal: True
+ shake-minify-css.cabal view
@@ -0,0 +1,41 @@+cabal-version: 1.18+name: shake-minify-css+version: 0.1.0.0+license: BSD3+license-file: LICENSE+copyright: Copyright: (c) 2019 Vanessa McHale+maintainer: vamchale@gmail.com+author: Vanessa McHale+synopsis: Shake rules for CSS+description:+ Sensibly use [shake](https://shakebuild.com/) to minify CSS.+category: Development, Shake+build-type: Simple+extra-source-files:+ cabal.project.local+extra-doc-files: README.md++source-repository head+ type: darcs+ location: https://hub.darcs.net/vmchale/shake-minify-css++library+ exposed-modules:+ Development.Shake.MinifyCSS+ hs-source-dirs: src+ default-language: Haskell2010+ ghc-options: -Wall+ build-depends:+ base >=4.3 && <5,+ shake >=0.14,+ hasmin -any,+ text -any,+ directory -any,+ filepath -any++ if impl(ghc >=8.0)+ ghc-options: -Wincomplete-uni-patterns -Wincomplete-record-updates+ -Wredundant-constraints -Wnoncanonical-monad-instances++ if impl(ghc >=8.4)+ ghc-options: -Wmissing-export-lists
+ src/Development/Shake/MinifyCSS.hs view
@@ -0,0 +1,48 @@+module Development.Shake.MinifyCSS ( -- * Rules+ minifyCSSRules+ , minifyCSSRulesWith+ -- * Actions+ , minifyCSSAction+ , minifyCSSActionWith+ ) where++import qualified Data.Text.IO as TIO+import Development.Shake+import Hasmin+import System.Directory (createDirectoryIfMissing)+import System.FilePath (takeDirectory)++minifyCSSRules :: FilePath -- ^ Source file+ -> FilePath -- ^ Destination/target+ -> Rules ()+minifyCSSRules =+ minifyCSSRulesWith defaultConfig++minifyCSSRulesWith :: Config+ -> FilePath -- ^ Source file+ -> FilePath -- ^ Destination/target+ -> Rules ()+minifyCSSRulesWith cfg src tgt =+ tgt %> \out ->+ minifyCSSActionWith cfg src out++minifyCSSAction :: FilePath -- ^ Source file+ -> FilePath -- ^ Destination/target+ -> Action ()+minifyCSSAction =+ minifyCSSActionWith defaultConfig++minifyCSSActionWith :: Config+ -> FilePath -- ^ Source file+ -> FilePath -- ^ Destination/target+ -> Action ()+minifyCSSActionWith cfg src tgt = do+ need [src]+ let tgtDir = takeDirectory tgt+ traced ("Create directory (" ++ tgtDir ++ ")") $+ createDirectoryIfMissing True tgtDir+ traced ("Minify CSS (" ++ tgt ++ ")") $ do+ contents <- TIO.readFile src+ case minifyCSSWith cfg contents of+ Right x -> TIO.writeFile tgt x+ Left y -> error y