Skip to content

Style/userStyle CSS files should be served in isolated directories #730

@spring-raining

Description

@spring-raining

From #728 (comment):

指定したスタイルシートと同名のファイルがinputファイルの場所に存在する場合の問題

--styleオプションで指定したスタイルシートと同名のファイルがinputファイルの場所に存在する場合に、指定したスタイルシートではなく、inputファイルの場所に存在するスタイルシートが適用されてしまう問題があります。

例:

$ tree
.
├── content
│   ├── index.html
│   └── style.css
└── style.css

$ cat content/index.html
<h1>Hello World!</h1>

$ cat content/style.css 
h1 {
  color: red;
}

$ cat style.css 
h1 {
  color: green;
}

$ ../../vivliostyle-cli/dist/cli.js preview content/index.html --style style.css
INFO Start preview

Vivliostyle CLI v10.3.0
║ 📘 Up and running (press Ctrl+C to quit)
╙─ Preview URL: http://localhost:13000/__vivliostyle-viewer/index.html#src=http://localhost:13000/vivliostyle/index.html&bookMode=true&renderAllPages=true&style=/vivliostyle/style.css

この結果のプレビュー表示を見ると、カレントディレクトリの style.css ではなく、content ディレクトリ内の style.css が適用されていることがわかります。

Preview URL で、src=http://localhost:13000/vivliostyle/index.htmlstyle=/vivliostyle/style.css が同じディレクトリ /vivliostyle/ にあるのが問題ではないかと思います。--style/--user-style オプションで指定したスタイルシートは、別のディレクトリにホストされるべきではないでしょうか。

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions