Skip to content
This repository was archived by the owner on Jan 18, 2022. It is now read-only.
This repository was archived by the owner on Jan 18, 2022. It is now read-only.

Use rollup to transform styles before applying scope to scoped styles #300

Open
@khalyomede

Description

@khalyomede

Version

5.0.0

Reproduction link

None (this is an issue in the build step).

Steps to reproduce

Compile an SFC that requires sass files from node modules.

What is expected?

To find the sass files correctly from node_modules.

What is actually happening?

Sass files are not found.


I use the plugin to compile an SFC that import a sass file from node_modules. Here is my rollup.config.js:

import vue from "rollup-plugin-vue";
import commonjs from "rollup-plugin-commonjs";
import nodeResolve from "rollup-plugin-node-resolve";
import babel from "rollup-plugin-babel";
import replace from "rollup-plugin-replace";

const { PRODUCTION } = process.env;

export default {
  input: "src/js/index.js",
  output: {
    format: "iife",
    file: "dist/js/index.js"
  },
  plugins: [
    babel({
      presets: ["@babel/preset-env"],
      runtimeHelpers: true,
      plugins: ["@babel/plugin-proposal-export-default-from"]
    }),
    commonjs(),
    nodeResolve(),
    vue(),
    replace({
      "process.env.NODE_ENV": JSON.stringify(PRODUCTION ? "production" : "development")
    })
  ]
};

And here is my SFC (producing the error):

<template lang="pug">
  mdc-button Test
</template>
<script>
import { MdcButton } from "material-components-web-vue";

export default {
  components: {
    MdcButton
  }
};
</script>
<style lang="scss">
@import "@material/button/mdc-button";
</style>

And here is the error:

$ rollup -c

src/js/index.js → dist/js/index.js...
[!] (plugin VuePlugin) Error: Error: Can't find stylesheet to import.
  src\js\page\Home.vue 14:9  root stylesheet
src\js\page\Home.vue
Error: Error: Can't find stylesheet to import.
  src\js\page\Home.vue 14:9  root stylesheet
    at Promise.all.descriptor.styles.map (C:\xampp\htdocs\test-bug\node_modules\rollup-plugin-vue\dist\rollup-plugin-vue.js:241:31)

Does vue template compiler tries to load using CSS3 @import instead of finding from node_modules?

I read those 2 issues:

But it seems not working either (as I do not have the exact code the others persons used I post my full config here and hope someone can answer this tricky question I am struggling with).

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions