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

CSP Violation #75

Closed
sheremet-va opened this issue Aug 2, 2021 · 9 comments
Closed

CSP Violation #75

sheremet-va opened this issue Aug 2, 2021 · 9 comments

Comments

@sheremet-va
Copy link

Снимок экрана 2021-08-02 в 15 20 44
Снимок экрана 2021-08-02 в 15 23 03

This package is inlining css, which violates my CSP rules (default-src 'self'). I know I can enable unsafe-inline but this is unsafe and kinda defeats the purpose.

Is it possible to bundle this package in some other way?

@XiongAmao
Copy link
Owner

XiongAmao commented Aug 17, 2021

Sorry for the late reply.

I have released v1.2.2, which may fix this issue.
I extract css to dist/external-css/vue-easy-lightbox.css. And .js in this directory(dist/external-css/*.js) do not contain inlining css.

// in this path vue-easy-lightbox/dist/external-css/*.js 
import VueEasyLightbox from 'vue-easy-lightbox/dist/external-css/vue-easy-lightbox.es5.esm.min.js'

// you need to import css yourself
import 'vue-easy-lightbox/external-css/vue-easy-lightbox.css' 

@sheremet-va
Copy link
Author

sheremet-va commented Aug 18, 2021

Hey! Thank you very much for the clean fix!

Importing in typescript works, but typechecking gives me this error:

Снимок экрана 2021-08-18 в 15 26 00

(importing css doesn't give me any errors)

For now I fixed it locally with:

declare module 'vue-easy-lightbox/dist/external-css/vue-easy-lightbox.es5.common.min.js';

But I think vue-easy-lightbox should support it - since the package has types/index.d.ts , TypeScript support is expected.

@XiongAmao
Copy link
Owner

I did a search. But haven't found how to add d.ts for named module path dist/*.js yet.

As you mentioned, add d.ts locally is one way:

declare module 'vue-easy-lightbox/dist/external-css/vue-easy-lightbox.es5.common.min' {
  import VueEasyLightbox from 'vue-easy-lightbox'
  export default VueEasyLightbox
}

The other way, if you're using webpack:
https://webpack.js.org/configuration/resolve/#resolvealias

// wepback.config.js
module.exports = {
  //...
  resolve: {
    alias: {
      'vue-easy-lightbox$': 'vue-easy-lightbox/dist/external-css/vue-easy-lightbox.es5.common.min.js',
    },
  },
};

// in your component
import VueEasyLightbox from 'vue-easy-lightbox' // work

@sheremet-va
Copy link
Author

Thank you for your advice with aliasing. Will do that.

I think it can be added to the docs.

@XiongAmao
Copy link
Owner

@sheremet-va
Copy link
Author

Thank you! Closing the issue now

@ghost
Copy link

ghost commented Jul 21, 2022

Hi @XiongAmao are external-css builds available for vue2 component or only vue3? thanks

@XiongAmao
Copy link
Owner

@ekrausso
Hi, it is released in v0.19.0.

@ghost
Copy link

ghost commented Jul 22, 2022

@XiongAmao great!! thanks :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants