diff --git a/client/index.js b/client/index.js index a46f28e..b027b0b 100644 --- a/client/index.js +++ b/client/index.js @@ -5,6 +5,7 @@ const {promisify} = require('es6-promisify'); const currify = require('currify/legacy'); const {js: loadJS} = require('load.js'); const series = require('async/series'); +const monaco = require('monaco-editor'); const _series = promisify(series); const loadSocket = currify(_loadSocket); @@ -27,12 +28,10 @@ module.exports = (el, options, callback = options) => { const getElement = () => el; const getPrefix = () => prefix; - const monaco = promisify(loadMonaco); const deepword = api(parseElement(el), options); loadAll(prefix) .then(getPrefix) - .then(monaco) .then(getElement) .then(parseElement) .then(init) @@ -59,20 +58,7 @@ function loadAll(prefix) { ]); } -function loadMonaco(prefix, fn) { - const {require} = window; - const vs = transformName(prefix, 'min/vs'); - - require.config({ - paths: { vs } - }); - - require(['vs/editor/editor.main'], noArg(fn)); -} - function init(el) { - const {monaco} = window; - return monaco.editor.create(el, { minimap: { enabled: false, diff --git a/package.json b/package.json index 7f0bf95..235fea8 100644 --- a/package.json +++ b/package.json @@ -94,6 +94,7 @@ "load.js": "^1.1.4", "minifyify": "^7.3.3", "mkdirp": "^0.5.1", + "monaco-editor-webpack-plugin": "^1.1.0", "nodemon": "^1.10.2", "nyc": "^11.0.2", "redrun": "^6.0.0", diff --git a/webpack.config.js b/webpack.config.js index 21d31df..db9a010 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -13,6 +13,7 @@ const distDev = path.resolve(__dirname, 'dist-dev'); const devtool = isDev ? 'eval' : 'source-map'; const notEmpty = (a) => a; const clean = (array) => array.filter(notEmpty); +const MonacoWebpackPlugin = require('monaco-editor-webpack-plugin'); const rules = clean([ !isDev && { @@ -44,6 +45,9 @@ module.exports = { module: { rules, }, + plugins: [ + new MonacoWebpackPlugin() + ], }; function devtoolModuleFilenameTemplate(info) {