sarsamurmu / reboost

A super fast dev server for rapid web development
MIT License
61 stars 3 forks source link

PostCSSPlugin - error not caught #36

Closed GHNewbiee closed 4 years ago

GHNewbiee commented 4 years ago

Error path.join(__dirname, {}, 'tailwindCSS/tailwindcss.config.js') is not caught. It seems that postcss.config.js does not get parsed at all.

Workspace

root/
  .config_files/
    postCSS/
      tailwindCSS/
        tailwindcss.config.js
      postcss.config.js

package.json

...
  "devDependencies": {
    "reboost": "^0.12.1"
  },
  "dependencies": {
    "lit-element": "^2.4.0",
    "tailwindcss": "1.7.6"

reboost.js

...
start({
  ...
  plugins: [
    PostCSSPlugin(
      {
        path: path.join(process.cwd(), '.config_files/postCSS'),
      //path: path.join(process.cwd(), {}, '.config_files/postCSS'), this error is caught
        ctx: { }
      }
    )
  ]
})

postcss.config.js

const path = require('path');

module.exports = ({ file, ctx, env }) => ({
  plugins: [
    require('tailwindcss')(path.join(__dirname, {}, 'tailwindCSS/tailwindcss.config.js')) // this error is not caught
  ]
})
sarsamurmu commented 4 years ago

Seems like I forgot to log error here - https://github.com/sarsamurmu/reboost/blob/primary/packages/core/src/node/plugins/postcss.ts#L106. It will be fixed in the next release.

GHNewbiee commented 4 years ago

Just FYI, in the case of path: path.join(process.cwd(), {}, '.config_files/postCSS'), // this error is caught the execution was terminated. But, in the case of require('tailwindcss')(path.join(__dirname, {}, 'tailwindCSS/tailwindcss.config.js')) // this error is not caught the execution was not (even) terminated at all!

sarsamurmu commented 4 years ago

Fixed in v0.13.0

GHNewbiee commented 4 years ago

Unfortunately, the problem still exists.

Even wrong path: path.join(process.cwd(), '.cccccconfig_files/ppppostCSS') is not enough to stop the execution!

The expected error PostCSSPlugin: The given path for options.path does not exist - ${options.path} is not displayed.

Does it run right in your system?

sarsamurmu commented 4 years ago

As far as I remember it worked correctly for me. Let me check again tomorrow.

GHNewbiee commented 4 years ago

Just FYI,

reboost.js in project_root dir

const path = require('path');

const {
  start,
  builtInPlugins: {
    PostCSSPlugin
  }
} = require('reboost');

start({
  entries: [
    ['./src/index.js', './public/dist/index.js']
  ],
  contentServer: {
    root: './public',
    open: true
  },
  plugins: [
    PostCSSPlugin({
      path: path.join(process.cwd(), '.cccccconfig_files/ppppostCSS')
    })
  ]
});
sarsamurmu commented 4 years ago

Did you check it when PostCSS transforms a file? The error should be shown when PostCSSPlugin tries to transform a file.

sarsamurmu commented 4 years ago

Will reopen again if it still not works.

GHNewbiee commented 4 years ago

Did you check it when PostCSS transforms a file?

First, I was expecting a kind of "global" initialization with checks through "warming up" since it's a built-in plugin. Next, I thought that

const {
  start,
  builtInPlugins: {
    CSSPlugin,
    PostCSSPlugin,
    UsePlugin
  }
} = require('reboost');

start({
  plugins: [
    UsePlugin(
      {
        include: /.+\.css$/i,
        use: PostCSSPlugin(),
      }
    ),
    PostCSSPlugin({
      path: path.join(process.cwd(), '.config_files/postCSS'),
      ctx: { ... }
    }),
    CSSPlugin()
  ]
})

would be enough so that css transformations automatically take place every time I make a change into a source css file. Unless, I have to use CLI.

Please, when it is convenient for you, add some extra notes to the page with a very small example, how this plugin can be practically put in work. Just a simple and small css file or CSS-in-JS which is transformed. A limited template would be another possibility, too. Tia

sarsamurmu commented 4 years ago

Thanks for confirming and I will add some small example.