lasso-js / lasso-less

Lasso.js plugin to support compilation of less dependencies
7 stars 10 forks source link

Add outputLessBundle option to output the intermediate bundle file #34

Open cc-ebay opened 3 years ago

cc-ebay commented 3 years ago

With this option we can check the intermediate file. With the appropriate less options we can even use the source maps.

Ex:

  {plugin: 'lasso-less', config: {
    outputLessBundle: true,
    lessConfig: {
      env: "development",
      dumpLineNumbers: true,
      sourceMap: {
        sourceMapFileInline: true
      }
    }
  }}
DylanPiercey commented 3 years ago

@cc-ebay what is the use case here? This particular change is not going to mesh well with the existing lasso tooling, for example, a plugin that uploads assets to a resource server would not work with this.

cc-ebay commented 3 years ago

@DylanPiercey Being able to serve the lasso.less so we have something close to the .less source. Very useful when there are a lot of mixins.

DylanPiercey commented 3 years ago

@cc-ebay I'm not following what the actual end goal is here though. Is this something you want for dev mode? What is special about the less generated css vs the rest of the css that you want to do something different with?

Is it just about adding source maps?

cc-ebay commented 3 years ago

Yes, in dev mode you can see source maps to the bundle .less file (not the .css).

DylanPiercey commented 3 years ago

Since this module is setup to (when bundling is disabled) merge all the less into a single file, this should already be possible.

Does the following by itself not work for you?

  {plugin: 'lasso-less', config: {
    lessConfig: {
      env: "development",
      dumpLineNumbers: true,
      sourceMap: {
        sourceMapFileInline: true
      }
    }
  }}
DylanPiercey commented 3 years ago

Now that I am looking at it, this plugin actually does the less module concatenation to make the "single less file" and also inlines comments and such that is not going to work without modification using that sourcemap option. Even with your change to provide an option to extract the less to a different file, it would still not have the correct sourcemaps.

cc-ebay commented 3 years ago

I lost the changes but after patching the plugin options here https://github.com/marko-js-archive/marko-starter-lasso/blob/master/createLassoConfig.js#L74 I was able to see the source maps related to the bundle files. It is not as good as mapping to the single source files but better than having only .css.

Does not Chrome still need to be able to load the .less from disk ?

DylanPiercey commented 3 years ago

I see, if that is all you are going for then it should work to just make the config:

{
      plugin: "lasso-less",
      config: {
        lessConfig: {
          sourceMap: {
            sourceMapFileInline: true,
            outputSourceFiles: true
          }
        }
      }
    }