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

Support local resources for ReactiveHTML components #3241

Closed
ghost opened this issue Mar 14, 2022 · 2 comments · Fixed by #3284
Closed

Support local resources for ReactiveHTML components #3241

ghost opened this issue Mar 14, 2022 · 2 comments · Fixed by #3284
Labels
type: enhancement Minor feature or improvement to an existing feature

Comments

@ghost
Copy link

ghost commented Mar 14, 2022

Environment:

  • python=3.9
  • folium
  • ipywidgets
  • jupyterlab
  • jupytext
  • panel
  • pyproj
  • sentinelsat
  • vtk
  • plotly

Happens on multiple machines and on both Windows 10 and Ubuntu.

Description of expected behavior and the observed behavior

Trying to use panel.extend() with external javascript and/or css -files results in a failed import, citing a faulty MIME-type (text/html).

Complete, minimal, self-contained example code that reproduces the issue

import panel as pn
from panel.reactive import ReactiveHTML

class TestClass(ReactiveHTML):
    __javascript__ = ['./index.umd.js'] #point to local file, have tried both relative/absolute paths
    __css__ = ['./index.css'] #point to local file, have tried both relative/absolute paths
    
    _template = """
    <h1 id="hello">Hello World!</hi>
    """
    
pn.extension()

testClassInstance = TestClass()
testClassInstance

Stack traceback and/or browser JavaScript console output

Refused to apply style from 'http://localhost:8888/lab/workspaces/auto-9/tree/index.css' because its MIME type ('text/html') is not a supported stylesheet MIME type, and strict MIME checking is enabled.

This does however work when pointing to a CDN for example. I can only reproduce this bug with local files.

@philippjfr philippjfr added the type: enhancement Minor feature or improvement to an existing feature label Mar 14, 2022
@philippjfr philippjfr changed the title Importing external js/css files results in an error Support local resources for ReactiveHTML components Mar 14, 2022
@MarcSkovMadsen
Copy link
Collaborator

MarcSkovMadsen commented Mar 14, 2022

Local files and/ or raw_css would be very nice indeed. I've been missing the raw_css possibility.

@MarcSkovMadsen
Copy link
Collaborator

It's a different issue. But we also still lack an api for providing _scripts from a .js file instead of a dictionary. This would make the development process much better as IDE can provide useful feedback.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: enhancement Minor feature or improvement to an existing feature
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants