Skip to content
This repository has been archived by the owner on Apr 8, 2022. It is now read-only.

How to import this library via ES import? #184

Closed
brylie opened this issue Oct 24, 2016 · 2 comments
Closed

How to import this library via ES import? #184

brylie opened this issue Oct 24, 2016 · 2 comments
Labels

Comments

@brylie
Copy link

brylie commented Oct 24, 2016

I have installed this project via npm install. How do I import Bootstrap Colorpicker, so that I can call it in a file?

@vmanyushin
Copy link

vmanyushin commented Dec 2, 2016

you can simply load it as any other node modules.

import "boostrap-colorpicker";
$('#colorPicker').colorpicker();

when i loading colorpicker in this way, he won't work, i get error

TypeError: $ is undefined[Learn More]
$.colorpicker = Colorpicker;

i fix this error by replace code in the beginning of plugin

line:20: function($)

to this

line:20: function(jQuery)

my webpack.config.js

const path = require("path");
const webpack = require("webpack");

module.exports = {
    entry: {
      app: ["./app.js"]
    },

    output: {
      path: path.resolve(__dirname, "build"),
      publicPath: "/assets/",
      filename: "bundle.js"
    },

    module: {
        loaders: [
            {
                test: /\.css$/,
                loader: "style-loader!css-loader"
            },
            {
                test: /\.scss$/,
                loader: "style-loader!css-loader!sass-loader"
            },
            {
                test: /\.js$/,
                exclude: /node_modules/,
                loader: "babel-loader"
            },
            {
                test: /\.eot(\?v=\d+\.\d+\.\d+)?$/,
                loader: "file?name=fonts/[name].[ext]"
            },
            {
                test: /\.(woff|woff2)$/,
                loader: "url?prefix=font/&limit=5000&name=fonts/[name].[ext]"
            },
            {
                test: /\.ttf(\?v=\d+\.\d+\.\d+)?$/,
                loader: "url?limit=10000&mimetype=application/octet-stream&name=fonts/[name].[ext]"
            },
            {
                test: /\.svg(\?v=\d+\.\d+\.\d+)?$/,
                loader: "url?limit=10000&mimetype=image/svg+xml&name=fonts/[name].[ext]"
            },
        ]
    },


    devServer: { inline: true },

    plugins: [
        new webpack.ProvidePlugin({
            jQuery: 'jquery',
            $: 'jquery',
            jquery: 'jquery'
        })
    ]

}

@itsjavi itsjavi added the bug label Dec 28, 2016
@archonic
Copy link

archonic commented Feb 9, 2021

The original question doesn't seem to be answered here.

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

No branches or pull requests

4 participants