Class MinimizeSassManager
- java.lang.Object
-
- org.ametys.runtime.plugin.component.AbstractLogEnabled
-
- org.ametys.core.minimize.css.sass.MinimizeSassManager
-
- All Implemented Interfaces:
LogEnabled
,Initializable
,Component
,Contextualizable
,Serviceable
public class MinimizeSassManager extends AbstractLogEnabled implements Component, Serviceable, Initializable, Contextualizable
Minimize manager for CSS files
-
-
Field Summary
Fields Modifier and Type Field Description private Context
_context
private io.bit3.jsass.Compiler
_jsassCompiler
private JSASSResourceURIExtensionPoint
_jsassResourceURIExtensionPoint
private ProxiedContextPathProvider
_proxiedContextPathProvider
private SourceResolver
_resolver
private List<SassFunctionsProvider>
_sassFunctionsProviders
private SourceMapCache
_sourceMapCache
static String
ROLE
The avalon ROLE
-
Constructor Summary
Constructors Constructor Description MinimizeSassManager()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private io.bit3.jsass.Output
_compileCss(String content, String fileName, URI uri, boolean minimize, String extension)
Compile a SCSS and output the JSASS result containing the content and source mapString
compileCss(String content, String sassLocation, String location, boolean minimize, long lastModified)
Compile a sass file.void
contextualize(Context context)
String
generateCssSourceMap(String content, String location, String extension, String internalContextPath, String externalContextPath, boolean minimize, long lastModified)
Generate the source map of compiled sass file.void
initialize()
void
service(ServiceManager smanager)
-
Methods inherited from class org.ametys.runtime.plugin.component.AbstractLogEnabled
getLogger, setLogger
-
-
-
-
Field Detail
-
_jsassCompiler
private io.bit3.jsass.Compiler _jsassCompiler
-
_jsassResourceURIExtensionPoint
private JSASSResourceURIExtensionPoint _jsassResourceURIExtensionPoint
-
_resolver
private SourceResolver _resolver
-
_sassFunctionsProviders
private List<SassFunctionsProvider> _sassFunctionsProviders
-
_sourceMapCache
private SourceMapCache _sourceMapCache
-
_proxiedContextPathProvider
private ProxiedContextPathProvider _proxiedContextPathProvider
-
-
Constructor Detail
-
MinimizeSassManager
public MinimizeSassManager()
-
-
Method Detail
-
initialize
public void initialize() throws Exception
- Specified by:
initialize
in interfaceInitializable
- Throws:
Exception
-
contextualize
public void contextualize(Context context) throws ContextException
- Specified by:
contextualize
in interfaceContextualizable
- Throws:
ContextException
-
service
public void service(ServiceManager smanager) throws ServiceException
- Specified by:
service
in interfaceServiceable
- Throws:
ServiceException
-
compileCss
public String compileCss(String content, String sassLocation, String location, boolean minimize, long lastModified) throws URISyntaxException, io.bit3.jsass.CompilationException, IOException
Compile a sass file. The source map of the file is generated and stored in the source map cache- Parameters:
content
- The content of the sass filesassLocation
- The location of the sass file, e.g. plugin:core-ui:/resources/example/test.scsslocation
- The location of the compiled css, e.g. plugin:core-ui:/resources/example/test.css or plugin:core-ui:/resources/example/test.min.cssminimize
- Minimize the outputlastModified
- The date of last modification- Returns:
- The content of the compiled, and optionally minimized, sass file
- Throws:
URISyntaxException
- If an exception occurredio.bit3.jsass.CompilationException
- If an exception occurredIOException
- If an exception occurred
-
generateCssSourceMap
public String generateCssSourceMap(String content, String location, String extension, String internalContextPath, String externalContextPath, boolean minimize, long lastModified) throws URISyntaxException, io.bit3.jsass.CompilationException, IOException
Generate the source map of compiled sass file. The source map of the file is generated and stored in the source map cache- Parameters:
content
- The content of the filelocation
- The location of the source map file, e.g. plugin:core-ui:/resources/example/test.scss.map or plugin:core-ui:/resources/example/test.css.mapextension
- The extension of the sass file, e.g. scss or sassinternalContextPath
- The internal context pathexternalContextPath
- The external context pathminimize
- Minimize the outputlastModified
- The date of last modification- Returns:
- The content of the source map, or null if no source map was generated
- Throws:
URISyntaxException
- If an exception occurredio.bit3.jsass.CompilationException
- If an exception occurredIOException
- If an exception occurred
-
_compileCss
private io.bit3.jsass.Output _compileCss(String content, String fileName, URI uri, boolean minimize, String extension) throws URISyntaxException, io.bit3.jsass.CompilationException
Compile a SCSS and output the JSASS result containing the content and source map- Parameters:
content
- The content of the filefileName
- The name of the compiled sass file, e.g. test.css or test.min.cssuri
- The contextualized uri of the sass file, e.g. /EXTERNAL_CONTEXT/plugins/core-ui/resources/example/test.scssminimize
- Minimize the outputextension
- The sass extension such as scss or sass- Returns:
- The output of the compilation
- Throws:
URISyntaxException
- if an error occurred with the uri syntaxio.bit3.jsass.CompilationException
- if an error occured when compiling the sass
-
-