Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CSS precompiling does not work in JavaScript API #2030

Closed
KAWATAAAAAA opened this issue Feb 15, 2021 · 2 comments
Closed

CSS precompiling does not work in JavaScript API #2030

KAWATAAAAAA opened this issue Feb 15, 2021 · 2 comments

Comments

@KAWATAAAAAA
Copy link

KAWATAAAAAA commented Feb 15, 2021

At the use Javascript API case :

Less (maybe SASS etc) in the application doesn't work. It prompts that you need to install it to run.

It doesn't work to install less in the application, but it can be solved in the CLI tool based on the secondary development of vite, but I think it should not be installed in the CLI tool project, but should be explicitly installed in the application

  const command = "serve"
  const mode = "development"
  import { InlineConfig } from "vite"
  import vue from "@vitejs/plugin-vue"
  import { babel } from "@rollup/plugin-babel"
  const { createServer } = require("vite")

  const path = require("path")
  const userConfig = require(`${process.cwd()}/tiny.config`)
  const target = typeof userConfig === 'function' ? userConfig(command,mode) : userConfig

const tinyCliConfig = {
  
    configFile:false,//tiny.config.js
    root:process.cwd(),
    plugins: [
        vue(),
        babel({
          babelHelpers: "bundled",
          exclude: "node_module/**"
        })
      ],
    resolve:{
        alias: {
          "@": path.resolve(process.cwd(), "src"),
        },
      },
}
const finalConfig:InlineConfig = {
    ...userConfig,
    ...tinyCliConfig
}
console.log(finalConfig)
module.exports = async () => {
    // process.cwd  current workplace dir
    // __dirname  current runtime module dir
    const server = await createServer(finalConfig)
    await server.listen()
}

Error Info

[plugin:vite:css] Preprocessor dependency "less" not found. Did you install it?
/Users/MoreIsLess/MyWork/Vue23/vue-element-plus-admin-ts/src/App.vue
at loadPreprocessor (/Users/MoreIsLess/MyWork/tiny-cli/node_modules/vite/dist/node/chunks/dep-074f1849.js:18127:15)
at less (/Users/MoreIsLess/MyWork/tiny-cli/node_modules/vite/dist/node/chunks/dep-074f1849.js:18209:22)
at compileCSS (/Users/MoreIsLess/MyWork/tiny-cli/node_modules/vite/dist/node/chunks/dep-074f1849.js:17926:40)
at async TransformContext.transform (/Users/MoreIsLess/MyWork/tiny-cli/node_modules/vite/dist/node/chunks/dep-074f1849.js:17614:50)
at async Object.transform (/Users/MoreIsLess/MyWork/tiny-cli/node_modules/vite/dist/node/chunks/dep-074f1849.js:45854:30)
at async transformRequest (/Users/MoreIsLess/MyWork/tiny-cli/node_modules/vite/dist/node/chunks/dep-074f1849.js:61402:29)
at async /Users/MoreIsLess/MyWork/tiny-cli/node_modules/vite/dist/node/chunks/dep-074f1849.js:61505:32
Click out

System Info

  • vite v2.0.0-beta.69
  • mac v10.15.7
  • node v12.18.3
  • npm v6.14.6
@yyx990803
Copy link
Member

FYI this only happens when you are linking your CLI locally, but it's fixed anyway.

@KAWATAAAAAA
Copy link
Author

新年快乐,谢谢尤大。😄😄😄。

@github-actions github-actions bot locked and limited conversation to collaborators Jul 16, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants