2017-04-22 19:24:52 +00:00
|
|
|
var
|
2022-05-08 14:13:50 +00:00
|
|
|
browserslist = require('browserslist'),
|
2017-04-22 19:24:52 +00:00
|
|
|
console = require('better-console'),
|
|
|
|
config = require('./user'),
|
|
|
|
release = require('./project/release')
|
|
|
|
;
|
|
|
|
|
2022-05-08 14:13:50 +00:00
|
|
|
var defaultBrowsers = browserslist(browserslist.defaults)
|
|
|
|
var userBrowsers = browserslist()
|
|
|
|
var hasBrowserslistConfig = JSON.stringify(defaultBrowsers) !== JSON.stringify(userBrowsers)
|
|
|
|
|
|
|
|
var overrideBrowserslist = hasBrowserslistConfig ? undefined : [
|
|
|
|
'last 2 versions',
|
|
|
|
'> 1%',
|
|
|
|
'opera 12.1',
|
|
|
|
'bb 10',
|
|
|
|
'android 4'
|
|
|
|
]
|
2017-04-22 19:24:52 +00:00
|
|
|
|
|
|
|
module.exports = {
|
|
|
|
|
|
|
|
banner : release.banner,
|
|
|
|
|
|
|
|
log: {
|
|
|
|
created: function(file) {
|
|
|
|
return 'Created: ' + file;
|
|
|
|
},
|
|
|
|
modified: function(file) {
|
|
|
|
return 'Modified: ' + file;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
filenames: {
|
|
|
|
concatenatedCSS : 'semantic.css',
|
|
|
|
concatenatedJS : 'semantic.js',
|
|
|
|
concatenatedMinifiedCSS : 'semantic.min.css',
|
|
|
|
concatenatedMinifiedJS : 'semantic.min.js',
|
|
|
|
concatenatedRTLCSS : 'semantic.rtl.css',
|
|
|
|
concatenatedMinifiedRTLCSS : 'semantic.rtl.min.css'
|
|
|
|
},
|
|
|
|
|
|
|
|
regExp: {
|
|
|
|
|
|
|
|
comments: {
|
|
|
|
|
|
|
|
// remove all comments from config files (.variable)
|
|
|
|
variables : {
|
|
|
|
in : /(\/\*[\s\S]+?\*\/+)[\s\S]+?\/\* End Config \*\//,
|
|
|
|
out : '$1',
|
|
|
|
},
|
|
|
|
|
|
|
|
// add version to first comment
|
|
|
|
license: {
|
2022-05-08 14:13:50 +00:00
|
|
|
in : /(^\/\*[\s\S]+)(# Fomantic-UI )([\s\S]+?\*\/)/,
|
2017-04-22 19:24:52 +00:00
|
|
|
out : '$1$2' + release.version + ' $3'
|
|
|
|
},
|
|
|
|
|
|
|
|
// adds uniform spacing around comments
|
|
|
|
large: {
|
|
|
|
in : /(\/\*\*\*\*[\s\S]+?\*\/)/mg,
|
|
|
|
out : '\n\n$1\n'
|
|
|
|
},
|
|
|
|
small: {
|
|
|
|
in : /(\/\*---[\s\S]+?\*\/)/mg,
|
|
|
|
out : '\n$1\n'
|
|
|
|
},
|
|
|
|
tiny: {
|
|
|
|
in : /(\/\* [\s\S]+? \*\/)/mg,
|
|
|
|
out : '\n$1'
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
theme: /.*(\/|\\)themes(\/|\\).*?(?=(\/|\\))/mg
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
settings: {
|
|
|
|
|
|
|
|
/* Remove Files in Clean */
|
|
|
|
del: {
|
|
|
|
silent : true
|
|
|
|
},
|
|
|
|
|
|
|
|
concatCSS: {
|
|
|
|
rebaseUrls: false
|
|
|
|
},
|
|
|
|
|
|
|
|
/* Comment Banners */
|
|
|
|
header: {
|
2022-05-08 14:13:50 +00:00
|
|
|
year : (new Date()).getFullYear(),
|
2017-04-22 19:24:52 +00:00
|
|
|
title : release.title,
|
|
|
|
version : release.version,
|
|
|
|
repository : release.repository,
|
|
|
|
url : release.url
|
|
|
|
},
|
|
|
|
|
|
|
|
plumber: {
|
|
|
|
less: {
|
|
|
|
errorHandler: function(error) {
|
|
|
|
var
|
|
|
|
regExp = {
|
|
|
|
variable : /@(\S.*?)\s/,
|
|
|
|
theme : /themes[\/\\]+(.*?)[\/\\].*/,
|
|
|
|
element : /[\/\\]([^\/\\*]*)\.overrides/
|
|
|
|
},
|
|
|
|
theme,
|
|
|
|
element
|
|
|
|
;
|
2022-05-08 14:13:50 +00:00
|
|
|
if(error && error.filename && error.filename.match(/theme.less/)) {
|
|
|
|
if (error.line == 9) {
|
|
|
|
element = regExp.variable.exec(error.message)[1];
|
|
|
|
if (element) {
|
2017-04-22 19:24:52 +00:00
|
|
|
console.error('Missing theme.config value for ', element);
|
|
|
|
}
|
|
|
|
console.error('Most likely new UI was added in an update. You will need to add missing elements from theme.config.example');
|
2022-05-08 14:13:50 +00:00
|
|
|
} else if (error.line == 73) {
|
2017-04-22 19:24:52 +00:00
|
|
|
element = regExp.element.exec(error.message)[1];
|
|
|
|
theme = regExp.theme.exec(error.message)[1];
|
|
|
|
console.error(theme + ' is not an available theme for ' + element);
|
2022-05-08 14:13:50 +00:00
|
|
|
} else {
|
|
|
|
console.error(error);
|
2017-04-22 19:24:52 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
2022-05-08 14:13:50 +00:00
|
|
|
throw new Error(error);
|
2017-04-22 19:24:52 +00:00
|
|
|
}
|
|
|
|
this.emit('end');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
/* What Browsers to Prefix */
|
|
|
|
prefix: {
|
2022-05-08 14:13:50 +00:00
|
|
|
overrideBrowserslist
|
2017-04-22 19:24:52 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
/* File Renames */
|
|
|
|
rename: {
|
|
|
|
minJS : { extname : '.min.js' },
|
|
|
|
minCSS : { extname : '.min.css' },
|
|
|
|
rtlCSS : { extname : '.rtl.css' },
|
|
|
|
rtlMinCSS : { extname : '.rtl.min.css' }
|
|
|
|
},
|
|
|
|
|
|
|
|
/* Minified CSS Concat */
|
|
|
|
minify: {
|
2022-05-08 14:13:50 +00:00
|
|
|
level: {
|
|
|
|
1: {
|
|
|
|
inline : false
|
|
|
|
}
|
|
|
|
}
|
2017-04-22 19:24:52 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
/* Minified JS Settings */
|
|
|
|
uglify: {
|
2019-07-31 12:48:02 +00:00
|
|
|
mangle : true,
|
|
|
|
output: {
|
|
|
|
comments: 'some'
|
|
|
|
}
|
2017-04-22 19:24:52 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
/* Minified Concat CSS Settings */
|
|
|
|
concatMinify: {
|
2022-05-08 14:13:50 +00:00
|
|
|
level: {
|
|
|
|
1: {
|
|
|
|
inline : false,
|
|
|
|
specialComments : false
|
|
|
|
}
|
|
|
|
}
|
2017-04-22 19:24:52 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
/* Minified Concat JS */
|
|
|
|
concatUglify: {
|
2019-07-31 12:48:02 +00:00
|
|
|
mangle : true,
|
|
|
|
output: {
|
|
|
|
comments: 'some'
|
|
|
|
}
|
2017-04-22 19:24:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
};
|