Skip to content
This repository has been archived by the owner on Sep 11, 2020. It is now read-only.

v2.x Using with webpack

Pavel Linkesch edited this page Apr 26, 2016 · 4 revisions

Using with webpack

Example index.js file:

var MediumEditor = require('medium-editor');
var $ = require('jquery');
require('medium-editor-insert-plugin')($);

var editor = new MediumEditor('.editable');
$('.editable').mediumInsert({
    editor: editor
});

In order to use the plugin with webpack, you need to install imports-loader module. Here is an example of package.json:

{
  "scripts": {
    "build": "webpack src/index.js dist/index.js --config ./webpack.config.js --progress --colors"
  },
  "dependencies": {
    "medium-editor-insert-plugin": "^2.3.2"
  },
  "devDependencies": {
    "imports-loader": "^0.6.5",
    "webpack": "^1.12.11"
  }
}

webpack.config.js looks like this:

module.exports = {
  entry: "./src/index.js",
  module: {
    loaders: [
      {
        test: require.resolve("blueimp-file-upload"),
        loader: "imports?define=>false"
      },
      {
        test: require.resolve("medium-editor-insert-plugin"),
        loader: "imports?define=>false"
      }
    ]
  }
};

imports?define=>false forces webpack to use CommonJS instead of AMD.