diff options
author | Mike Greiling <mike@pixelcog.com> | 2017-07-18 03:30:11 -0500 |
---|---|---|
committer | Mike Greiling <mike@pixelcog.com> | 2017-07-18 03:54:38 -0500 |
commit | cb17564566cb0e7399053ad5ec9d2e0ef5f5340f (patch) | |
tree | 5b4d28eadbc382c7355e8e06245d3e65c2d2046b /config/webpack.config.js | |
parent | 0a7870937f28a8c4a6dc0e07b649176d69007f28 (diff) | |
download | gitlab-ce-cb17564566cb0e7399053ad5ec9d2e0ef5f5340f.tar.gz |
fix global context and relative_url_root for monaco editor
Diffstat (limited to 'config/webpack.config.js')
-rw-r--r-- | config/webpack.config.js | 29 |
1 files changed, 25 insertions, 4 deletions
diff --git a/config/webpack.config.js b/config/webpack.config.js index 398324569cb..fc644f9a9c9 100644 --- a/config/webpack.config.js +++ b/config/webpack.config.js @@ -4,11 +4,11 @@ var fs = require('fs'); var path = require('path'); var webpack = require('webpack'); var StatsPlugin = require('stats-webpack-plugin'); +var CopyWebpackPlugin = require('copy-webpack-plugin'); var CompressionPlugin = require('compression-webpack-plugin'); var NameAllModulesPlugin = require('name-all-modules-plugin'); var BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin; var WatchMissingNodeModulesPlugin = require('react-dev-utils/WatchMissingNodeModulesPlugin'); -var CopyWebpackPlugin = require('copy-webpack-plugin'); var ROOT_PATH = path.resolve(__dirname, '..'); var IS_PRODUCTION = process.env.NODE_ENV === 'production'; @@ -110,7 +110,16 @@ var config = { test: /locale\/\w+\/(.*)\.js$/, loader: 'exports-loader?locales', }, - ] + { + test: /monaco-editor\/\w+\/vs\/loader\.js$/, + use: [ + { loader: 'exports-loader', options: 'l.global' }, + { loader: 'imports-loader', options: 'l=>{},this=>l,AMDLoader=>this,module=>undefined' }, + ], + } + ], + + noParse: [/monaco-editor\/\w+\/vs\//], }, plugins: [ @@ -193,10 +202,22 @@ var config = { names: ['main', 'locale', 'common', 'runtime'], }), + // copy pre-compiled vendor libraries verbatim new CopyWebpackPlugin([ { - from: `../../../node_modules/monaco-editor/${IS_PRODUCTION ? 'min' : 'dev'}/vs`, - to: 'vs' + from: path.join(ROOT_PATH, `node_modules/monaco-editor/${IS_PRODUCTION ? 'min' : 'dev'}/vs`), + to: 'monaco-editor/vs', + transform: function(content, path) { + if (/\.js$/.test(path)) { + return ( + '(function(){\n' + + 'var define = this.define, require = this.require;\n' + + content + + '\n}.call(window.__monaco_context__ || (window.__monaco_context__ = {})));' + ); + } + return content; + } } ]), ], |