Skip to content

WebPack + CodeMirror + LoadMode #4838

@hacdias

Description

@hacdias

Hello!

I'm trying to use Codemirror with LoadMode alongside with WebPack. I thought about having something like:

new CopyWebpackPlugin([
{
    from: path.resolve(__dirname, '../node_modules/codemirror/mode/*/*'),
    to: path.join(config.build.assetsSubDirectory, 'js/codemirror/mode/[name]/[name].js')
}

and then have the CodeMirror to auto load the files but I can't get it to work. When I import 'loadmodule' I get this warning and it doesn't seem to be working:

warning  in ./~/codemirror/addon/mode/loadmode.js
51:6-19 Critical dependency: the request of a dependency is an expression

This is my import section of the file:

import 'codemirror/addons/mode/loadmodule'
import CodeMirror from 'codemirror'

I can use Codemirror and the themes. I'm not just being able to load the modes dynamically and I didn't want to import them at once.

How do I plug loadmode into CodeMirror?

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions