Split minify options for CSS and JS
This commit is contained in:
@ -21,12 +21,20 @@ struct Configuration: Codable {
|
||||
let fullScreenImageWidth: Int
|
||||
|
||||
/**
|
||||
Automatically minify all `.css` and `.js` resources which are copied
|
||||
Automatically minify all `.css` resources which are copied
|
||||
to the output folder.
|
||||
- Note: This option requires the `uglifyjs` and `clean-css` tools,
|
||||
- Note: This option requires the `clean-css` tool,
|
||||
which can be installed using the `install.sh` script in the root folder of the generator.
|
||||
*/
|
||||
let minifyCSSandJS: Bool
|
||||
let minifyCSS: Bool
|
||||
|
||||
/**
|
||||
Automatically minify all `.js` resources which are copied
|
||||
to the output folder.
|
||||
- Note: This option requires the `uglifyjs` tool,
|
||||
which can be installed using the `install.sh` script in the root folder of the generator.
|
||||
*/
|
||||
let minifyJavaScript: Bool
|
||||
|
||||
/**
|
||||
The path to the directory where the root element metadata is located.
|
||||
@ -76,8 +84,8 @@ struct Configuration: Codable {
|
||||
print(" Output folder: \(outputDirectory.path)")
|
||||
print(" Page width: \(pageImageWidth)")
|
||||
print(" Full-screen width: \(fullScreenImageWidth)")
|
||||
print(" Minify JavaScript: \(minifyCSSandJS)")
|
||||
print(" Minify CSS: \(minifyCSSandJS)")
|
||||
print(" Minify JavaScript: \(minifyJavaScript)")
|
||||
print(" Minify CSS: \(minifyCSS)")
|
||||
print(" Create markdown files: \(createMdFilesIfMissing)")
|
||||
}
|
||||
}
|
||||
|
@ -155,11 +155,11 @@ final class GenerationResultsHandler {
|
||||
|
||||
private func markForCopyOrMinification(file: String, source: String) {
|
||||
let ext = file.lastComponentAfter(".")
|
||||
if configuration.minifyCSSandJS, ext == "js" {
|
||||
if configuration.minifyJavaScript, ext == "js" {
|
||||
files.toMinify[file] = (source, .js)
|
||||
return
|
||||
}
|
||||
if configuration.minifyCSSandJS, ext == "css" {
|
||||
if configuration.minifyCSS, ext == "css" {
|
||||
files.toMinify[file] = (source, .css)
|
||||
return
|
||||
}
|
||||
|
@ -18,6 +18,10 @@ private func loadConfiguration(at configPath: String) -> Configuration? {
|
||||
print(" ")
|
||||
print(" Configuration file: \(configPath)")
|
||||
let configUrl = URL(fileURLWithPath: configPath)
|
||||
guard configUrl.exists else {
|
||||
print(" Error: Configuration file not found")
|
||||
return nil
|
||||
}
|
||||
var config: Configuration
|
||||
do {
|
||||
let data = try Data(contentsOf: configUrl)
|
||||
|
Reference in New Issue
Block a user