simonwep / pickr

🎨 Flat, simple, multi-themed, responsive and hackable Color-Picker library. No dependencies, no jQuery. Compatible with all CSS Frameworks e.g. Bootstrap, Materialize. Supports alpha channel, rgba, hsla, hsva and more!
https://simonwep.github.io/pickr
MIT License
4.29k stars 287 forks source link

Error: You may need an appropriate loader to handle this file type. #262

Closed shashiOrdant closed 3 years ago

shashiOrdant commented 3 years ago

I am using package via npm and using webpack as a module bundler in vue project.

I am getting following error image

This cause the error import Pickr from '@simonwep/pickr'; my .babelrc looks like { "presets": ["@babel/preset-env"], "plugins": ["@babel/plugin-syntax-dynamic-import", "transform-regenerator"] }

Your environment:

Version (see Pickr.version): 1.8.0
Used bundle (es5 or normal one): normal one
Used theme (default is classic): default
Browser-version:  Google chrome 87.0.4280.88 
Operating-system:  Windows 10
NateSeymour commented 3 years ago

Could you please post your webpack config as well? Thanks!

simonwep commented 3 years ago

Keep in mind that pickr is in the commonjs format and not an ES6 module. You won't be able to import it that way in a browser. It'll only work with a bundler (or as a bundle) as they're capable of dealing with both module types.

shashiOrdant commented 3 years ago

Could you please post your webpack config as well? Thanks!

@NateSeymour webpack.config looks like { "module": { "rules": [{ "test": {}, "exclude": {}, "loader": "babel-loader" }, { "test": {}, "loader": "css-loader" }, { "test": {}, "loader": "vue-loader" }] }, "resolve": { "alias": { ... }, "extensions": ["*", ".js", ".vue", ".json"] }, "plugins": [ { "definitions": { "process.env.NODE_ENV": "\"development\"", "server": "\"local\"" } }, { "resourceRegExp": {}, "contextRegExp": {} }, {}, { "options": { "hashFunction": "md5", "hashDigest": "base64", "hashDigestLength": 4 } } ], "entry": ["babel-polyfill", "./src/.../app.js"], "output": { "path": "D:\\...\\dist", "filename": "file-name.js", "chunkFilename": "[name].chunk.js" } }

simonwep commented 3 years ago

Closing due to inactivity.