PhpStorm: group/nest *.map files under source LESS

2019-05-31 07:12发布

Currently PhpStorm nests the generated *.css file under the *.less file when the file watcher is configured.

Is there any way to get the *.map file under there as well?

Example:

css file nested under less file

Is it one of these settings in the less.jar > plugin.xml file?

<idea-plugin version="2">
  <name>LESS support</name>
  <id>org.jetbrains.plugins.less</id>
  <category>HTML/JavaScript Development</category>
  <vendor>JetBrains</vendor>
  <description>
      <![CDATA[
      This plugin supports <a href="http://lesscss.org/">LESS</a> dialect of CSS that extends it with dynamic behavior such as variables, mixins, operators and functions.
      The following features are available:
        <ul>
        <li>Dedicated file type.</li>
        <li>LESS page under the Code Style node of the Settings/Preferences dialog.</li>
        <li>Syntax and error highlighting.</li>
        <li>Code formatting and folding.</li>
        <li>Code completion.</li>
        </ul>
      ]]>
   </description>
  <depends>com.intellij.css</depends>
  <depends>com.intellij.modules.lang</depends>
  <depends optional="true" config-file="less-watcher.xml">com.intellij.plugins.watcher</depends>
  <depends optional="true" config-file="less-copyright.xml">com.intellij.copyright</depends>

  <extensions defaultExtensionNs="com.intellij">
    <completion.contributor language="CSS" implementationClass="org.jetbrains.plugins.less.completion.LessCompletionContributor"/>
    <completion.contributor language="CSS" implementationClass="org.jetbrains.plugins.less.completion.LessDumbAwareCompletionContributor"/>
    <lang.implementationTextSelectioner language="LESS" implementationClass="com.intellij.psi.css.CSSImplementationTextSelectioner"/>
    <css.structureViewChildrenProvider implementation="org.jetbrains.plugins.less.fileStructure.LessStructureViewElementsProvider"/>

    <errorHandler implementation="com.intellij.diagnostic.ITNReporter"/>
    <lang.braceMatcher language="LESS" implementationClass="org.jetbrains.plugins.less.editor.LessBraceMatcher"/>
    <typedHandler implementation="org.jetbrains.plugins.less.editor.LessBraceInterpolationTypedHandler" id="lessInterpolationTypedHandler"/>
    <typedHandler implementation="org.jetbrains.plugins.less.editor.LessTypedHandler"/>
    <gotoSymbolContributor implementation="org.jetbrains.plugins.less.LessGotoSymbolContributor"/>
    <annotator language="LESS" implementationClass="org.jetbrains.plugins.less.annotator.LessColorAnnotator"/>
    <fileTypeFactory implementation="org.jetbrains.plugins.less.LESSFileTypeFactory"/>
    <lang.parserDefinition language="LESS" implementationClass="org.jetbrains.plugins.less.parser.LESSParserDefinition"/>
    <lang.syntaxHighlighterFactory language="LESS" implementationClass="org.jetbrains.plugins.less.highlighting.LessSyntaxHighlighterFactory"/>
    <lang.ast.factory language="LESS" implementationClass="org.jetbrains.plugins.less.psi.impl.LESSTreeElementFactory"/>
    <lang.commenter language="LESS" implementationClass="org.jetbrains.plugins.less.LESSCommenter"/>
    <psi.referenceContributor implementation="org.jetbrains.plugins.less.references.LESSReferenceContributor"/>
    <lang.findUsagesProvider language="LESS" implementationClass="org.jetbrains.plugins.less.usages.LESSFindUsagesProvider"/>
    <renameInputValidator implementation="org.jetbrains.plugins.less.rename.LESSRenameInputValidator"/>
    <extendWordSelectionHandler implementation="org.jetbrains.plugins.less.editor.LessExtendWordSelectionHandler"/>
    <colorSettingsPage implementation="org.jetbrains.plugins.less.highlighting.LESSColorsPage"/>
    <lang.braceMatcher language="LESS" implementationClass="com.intellij.psi.css.impl.util.editor.CssBraceMatcher"/>
    <lang.foldingBuilder language="LESS" implementationClass="com.intellij.psi.css.impl.util.editor.CssFoldingBuilder"/>
    <codeInsight.parameterInfo language="LESS" implementationClass="com.intellij.psi.css.parameterinfo.CssParameterInfoHandler"/>
    <enterHandlerDelegate implementation="org.jetbrains.plugins.less.editor.LESSEnterHandler" order="after EnterBetweenBracesHandler"/>
    <quoteHandler fileType="LESS" className="com.intellij.psi.css.impl.util.editor.CssQuoteHandler"/>
    <css.elementDescriptorProvider implementation="org.jetbrains.plugins.less.descriptors.LessElementDescriptorProvider" 
                                   order="last, before cssElementDescriptorProvider"/>
    <codeStyleSettingsProvider implementation="org.jetbrains.plugins.less.settings.LESSCodeStyleSettingsProvider"/>
    <langCodeStyleSettingsProvider implementation="org.jetbrains.plugins.less.settings.LESSLanguageCodeStyleSettingsProvider"/>
    <lang.formatter language="LESS" implementationClass="org.jetbrains.plugins.less.formatter.LessFormattingModelBuilder"/>
    <spellchecker.support language="LESS" implementationClass="org.jetbrains.plugins.less.spellchecking.LessSpellcheckingStrategy"/>
    <spellchecker.bundledDictionaryProvider implementation="org.jetbrains.plugins.less.spellchecking.LessBundledDictionaryProvider"/>
    <usageTypeProvider implementation="org.jetbrains.plugins.less.usages.LessUsageTypeProvider"/>
    <problemFileHighlightFilter implementation="org.jetbrains.plugins.less.highlighting.LessProblemFileHighlightFilter"/>
    <breadcrumbsInfoProvider implementation="org.jetbrains.plugins.less.editor.LessBreadcrumbsInfoProvider"/>
    <previewHintProvider implementation="org.jetbrains.plugins.less.editor.LessPreviewHintProvider"/>
    <embeddedTokenTypesProvider implementation="org.jetbrains.plugins.less.LessTokenTypesProvider"/>
    <include.provider implementation="org.jetbrains.plugins.less.include.LessFileIncludeProvider"/>
    <internalFileTemplate name="Less File"/>

    <stubIndex implementation="org.jetbrains.plugins.less.psi.stubs.LessMixinIndex"/>
    <stubIndex implementation="org.jetbrains.plugins.less.psi.stubs.LessVariableIndex"/>
    <stubElementTypeHolder class="org.jetbrains.plugins.less.LESSElementTypes"/>

    <lang.inspectionSuppressor language="LESS" implementationClass="org.jetbrains.plugins.less.inspections.suppress.LessInspectionSuppressor"/>
    <annotator language="LESS" implementationClass="org.jetbrains.plugins.less.annotator.LessErrorsAnnotator"/>
    <annotator language="CSS" implementationClass="org.jetbrains.plugins.less.annotator.LessErrorsAnnotator"/>
    <localInspection language="LESS" bundle="org.jetbrains.plugins.less.LESSBundle"
                     key="inspections.unresolved.variable.name"
                     groupKey="inspections.group.name" enabledByDefault="true" level="WARNING"
                     implementationClass="org.jetbrains.plugins.less.inspections.LessUnresolvedVariableInspection"/>
    <localInspection language="LESS" bundle="org.jetbrains.plugins.less.LESSBundle"
                     key="inspections.unresolved.mixin.name"
                     groupKey="inspections.group.name" enabledByDefault="true" level="WARNING"
                     implementationClass="org.jetbrains.plugins.less.inspections.LessUnresolvedMixinInspection"/>
    <localInspection language="LESS" bundle="org.jetbrains.plugins.less.LESSBundle"
                     key="inspections.resolved.without.imports.name"
                     groupKey="inspections.group.name" enabledByDefault="true" level="WEAK WARNING"
                     implementationClass="org.jetbrains.plugins.less.inspections.LessResolvedByNameOnlyInspection"/>
  </extensions>

  <extensions defaultExtensionNs="com.intellij.css">
    <supportedFileTypesProvider implementation="org.jetbrains.plugins.less.index.LessSupportedFileTypesProvider"/>
    <cssInspectionFilter language="LESS" implementationClass="org.jetbrains.plugins.less.inspections.LessCssInspectionFilter"/>
  </extensions>
</idea-plugin>

3条回答
Summer. ? 凉城
2楼-- · 2019-05-31 07:50

In my experience the configuration suggested by Iena doesn't work properly, to generate the file .map I configured the settings of the file watcher in this way:

Arguments:

--no-color $FileName$ 
--source map=$FileNameWithoutExtension$.css.map  
-source-map-url=$FileNameWithoutExtension$.css.map 

Output paths to refresh:

$FileNameWithoutExtension$.css:$FileNameWithoutExtension$.css.map

Is important that map filename contains the .css path in this way:

filename.css.map

The --source-map=filename command generate the .map file and -source-map-url=filename link it in the generated css file.

Here the configuration of my file watcher:

enter image description here

I hope can be useful.

Good code

D.

查看更多
Rolldiameter
3楼-- · 2019-05-31 07:53

Quick solution it: use flags in arguments

--source-map-less-inline --source-map-map-inline

It will store the maps inside of css files

However better solution use grunt/gulp builder...

查看更多
成全新的幸福
4楼-- · 2019-05-31 08:05

No, it has no relation to LESS plugin descriptor. And, yes, sure it is possible. All you need is to make sure that the pattern for .map file is is specified in 'Output paths to refresh' field of your file watcher. Like

$FileNameWithoutExtension$.css:$FileNameWithoutExtension$.map
查看更多
登录 后发表回答