295 lines
10 KiB
JavaScript
295 lines
10 KiB
JavaScript
/**
|
|
* Don't touch this file. It will be regenerated by theia build.
|
|
* To customize webpack configuration change /mnt/data/foss.global/git.zone/ide/applications/remote-theia/webpack.config.js
|
|
*/
|
|
// @ts-check
|
|
const path = require('path');
|
|
const webpack = require('webpack');
|
|
const yargs = require('yargs');
|
|
const resolvePackagePath = require('resolve-package-path');
|
|
const CopyWebpackPlugin = require('copy-webpack-plugin');
|
|
const CompressionPlugin = require('compression-webpack-plugin');
|
|
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
|
|
const { MonacoWebpackPlugin } = require('@theia/native-webpack-plugin/lib/monaco-webpack-plugins.js');
|
|
|
|
const outputPath = path.resolve(__dirname, 'lib', 'frontend');
|
|
const { mode, staticCompression } = yargs.option('mode', {
|
|
description: "Mode to use",
|
|
choices: ["development", "production"],
|
|
default: "production"
|
|
}).option('static-compression', {
|
|
description: 'Controls whether to enable compression of static artifacts.',
|
|
type: 'boolean',
|
|
default: true
|
|
}).argv;
|
|
const development = mode === 'development';
|
|
|
|
const plugins = [
|
|
new CopyWebpackPlugin({
|
|
patterns: [
|
|
{
|
|
// copy secondary window html file to lib folder
|
|
from: path.resolve(__dirname, 'src-gen/frontend/secondary-window.html')
|
|
},
|
|
{
|
|
// copy webview files to lib folder
|
|
from: path.join(resolvePackagePath('@theia/plugin-ext', __dirname), '..', 'src', 'main', 'browser', 'webview', 'pre'),
|
|
to: path.resolve(__dirname, 'lib', 'webview', 'pre')
|
|
}
|
|
,
|
|
{
|
|
// copy frontend plugin host files
|
|
from: path.join(resolvePackagePath('@theia/plugin-ext-vscode', __dirname), '..', 'lib', 'node', 'context', 'plugin-vscode-init-fe.js'),
|
|
to: path.resolve(__dirname, 'lib', 'frontend', 'context', 'plugin-vscode-init-fe.js')
|
|
}
|
|
,
|
|
{
|
|
// copy shell integration scripts
|
|
from: path.join(resolvePackagePath('@theia/terminal', __dirname), '..', 'src', 'node', 'shell-integrations'),
|
|
to: path.resolve(__dirname, 'lib', 'backend', 'shell-integrations')
|
|
}
|
|
]
|
|
}),
|
|
new webpack.ProvidePlugin({
|
|
// the Buffer class doesn't exist in the browser but some dependencies rely on it
|
|
Buffer: ['buffer', 'Buffer']
|
|
}),
|
|
new MonacoWebpackPlugin()
|
|
];
|
|
// it should go after copy-plugin in order to compress monaco as well
|
|
if (staticCompression) {
|
|
plugins.push(new CompressionPlugin({}));
|
|
}
|
|
|
|
module.exports = [{
|
|
mode,
|
|
plugins,
|
|
devtool: 'source-map',
|
|
entry: {
|
|
bundle: path.resolve(__dirname, 'src-gen/frontend/index.js'),
|
|
},
|
|
output: {
|
|
filename: '[name].js',
|
|
path: outputPath,
|
|
devtoolModuleFilenameTemplate: 'webpack:///[resource-path]?[loaders]',
|
|
globalObject: 'self'
|
|
},
|
|
target: 'web',
|
|
cache: staticCompression,
|
|
module: {
|
|
rules: [
|
|
{
|
|
test: /\.css$/,
|
|
exclude: /materialcolors\.css$|\.useable\.css$/,
|
|
use: ['style-loader', 'css-loader']
|
|
},
|
|
{
|
|
test: /materialcolors\.css$|\.useable\.css$/,
|
|
use: [
|
|
{
|
|
loader: 'style-loader',
|
|
options: {
|
|
esModule: false,
|
|
injectType: 'lazySingletonStyleTag',
|
|
attributes: {
|
|
id: 'theia-theme'
|
|
}
|
|
}
|
|
},
|
|
'css-loader'
|
|
]
|
|
},
|
|
{
|
|
test: /\.(ttf|eot|svg)(\?v=\d+\.\d+\.\d+)?$/,
|
|
type: 'asset',
|
|
parser: {
|
|
dataUrlCondition: {
|
|
maxSize: 10000,
|
|
}
|
|
},
|
|
generator: {
|
|
dataUrl: {
|
|
mimetype: 'image/svg+xml'
|
|
}
|
|
}
|
|
},
|
|
{
|
|
test: /\.(jpg|png|gif)$/,
|
|
type: 'asset/resource',
|
|
generator: {
|
|
filename: '[hash].[ext]'
|
|
}
|
|
},
|
|
{
|
|
// see https://github.com/eclipse-theia/theia/issues/556
|
|
test: /source-map-support/,
|
|
loader: 'ignore-loader'
|
|
},
|
|
{
|
|
test: /\.d\.ts$/,
|
|
loader: 'ignore-loader'
|
|
},
|
|
{
|
|
test: /\.js$/,
|
|
enforce: 'pre',
|
|
loader: 'source-map-loader',
|
|
exclude: /jsonc-parser|fast-plist|onigasm/
|
|
},
|
|
{
|
|
test: /\.woff(2)?(\?v=[0-9]\.[0-9]\.[0-9])?$/,
|
|
type: 'asset',
|
|
parser: {
|
|
dataUrlCondition: {
|
|
maxSize: 10000,
|
|
}
|
|
},
|
|
generator: {
|
|
dataUrl: {
|
|
mimetype: 'image/svg+xml'
|
|
}
|
|
}
|
|
},
|
|
{
|
|
test: /node_modules[\\|/](vscode-languageserver-types|vscode-uri|jsonc-parser|vscode-languageserver-protocol)/,
|
|
loader: 'umd-compat-loader'
|
|
},
|
|
{
|
|
test: /\.wasm$/,
|
|
type: 'asset/resource'
|
|
},
|
|
{
|
|
test: /\.plist$/,
|
|
type: 'asset/resource'
|
|
}
|
|
]
|
|
},
|
|
resolve: {
|
|
fallback: {
|
|
'child_process': false,
|
|
'crypto': false,
|
|
'net': false,
|
|
'path': require.resolve('path-browserify'),
|
|
'process': false,
|
|
'os': false,
|
|
'timers': false
|
|
},
|
|
alias: {
|
|
// Replace Monaco's nls module with Theia's localization-aware version.
|
|
// ESM exports are immutable so we cannot override localize/localize2 at runtime.
|
|
// Using the resolved absolute path ensures that both external imports
|
|
// (e.g. '@theia/monaco-editor-core/esm/vs/nls') and internal relative
|
|
// imports within Monaco (e.g. '../nls.js') are redirected.
|
|
[path.join(resolvePackagePath('@theia/monaco-editor-core', __dirname), '..', 'esm', 'vs', 'nls.js')]:
|
|
path.join(resolvePackagePath('@theia/monaco', __dirname), '..', 'lib', 'browser', 'monaco-nls.js')
|
|
},
|
|
extensions: ['.js']
|
|
},
|
|
stats: {
|
|
warnings: true,
|
|
children: true
|
|
},
|
|
ignoreWarnings: [
|
|
// Some packages do not have source maps, that's ok
|
|
/Failed to parse source map/,
|
|
{
|
|
// Monaco uses 'require' in a non-standard way
|
|
module: /@theia\/monaco-editor-core/,
|
|
message: /require function is used in a way in which dependencies cannot be statically extracted/
|
|
}
|
|
]
|
|
},
|
|
{
|
|
// The Monaco editor worker must be built separately without the NLS alias.
|
|
// The NLS alias redirects to monaco-nls.ts which imports from @theia/core,
|
|
// and those modules are not available in the web worker context.
|
|
mode,
|
|
devtool: 'source-map',
|
|
entry: {
|
|
'editor.worker': '@theia/monaco-editor-core/esm/vs/editor/common/services/editorWebWorkerMain.js'
|
|
},
|
|
output: {
|
|
filename: '[name].js',
|
|
path: outputPath,
|
|
devtoolModuleFilenameTemplate: 'webpack:///[resource-path]?[loaders]',
|
|
globalObject: 'self'
|
|
},
|
|
target: 'webworker',
|
|
cache: staticCompression,
|
|
resolve: {
|
|
extensions: ['.js']
|
|
},
|
|
ignoreWarnings: [
|
|
{
|
|
module: /@theia\/monaco-editor-core/,
|
|
message: /require function is used in a way in which dependencies cannot be statically extracted/
|
|
}
|
|
]
|
|
},
|
|
{
|
|
mode,
|
|
plugins: [
|
|
new MiniCssExtractPlugin({
|
|
// Options similar to the same options in webpackOptions.output
|
|
// both options are optional
|
|
filename: "[name].css",
|
|
chunkFilename: "[id].css",
|
|
}),
|
|
new MonacoWebpackPlugin(),
|
|
],
|
|
devtool: 'source-map',
|
|
entry: {
|
|
"secondary-window": path.resolve(__dirname, 'src-gen/frontend/secondary-index.js'),
|
|
},
|
|
output: {
|
|
filename: '[name].js',
|
|
path: outputPath,
|
|
devtoolModuleFilenameTemplate: 'webpack:///[resource-path]?[loaders]',
|
|
globalObject: 'self'
|
|
},
|
|
target: 'web',
|
|
cache: staticCompression,
|
|
module: {
|
|
rules: [
|
|
{
|
|
test: /.css$/i,
|
|
use: [MiniCssExtractPlugin.loader, "css-loader"]
|
|
},
|
|
{
|
|
test: /.wasm$/,
|
|
type: 'asset/resource'
|
|
}
|
|
]
|
|
},
|
|
resolve: {
|
|
fallback: {
|
|
'child_process': false,
|
|
'crypto': false,
|
|
'net': false,
|
|
'path': require.resolve('path-browserify'),
|
|
'process': false,
|
|
'os': false,
|
|
'timers': false
|
|
},
|
|
alias: {
|
|
// Replace Monaco's nls module with Theia's localization-aware version.
|
|
// ESM exports are immutable so we cannot override localize/localize2 at runtime.
|
|
// Using the resolved absolute path ensures that both external imports
|
|
// (e.g. '@theia/monaco-editor-core/esm/vs/nls') and internal relative
|
|
// imports within Monaco (e.g. '../nls.js') are redirected.
|
|
[path.join(resolvePackagePath('@theia/monaco-editor-core', __dirname), '..', 'esm', 'vs', 'nls.js')]:
|
|
path.join(resolvePackagePath('@theia/monaco', __dirname), '..', 'lib', 'browser', 'monaco-nls.js')
|
|
},
|
|
extensions: ['.js']
|
|
},
|
|
stats: {
|
|
warnings: true,
|
|
children: true
|
|
},
|
|
ignoreWarnings: [
|
|
{
|
|
// Monaco uses 'require' in a non-standard way
|
|
module: /@theia\/monaco-editor-core/,
|
|
message: /require function is used in a way in which dependencies cannot be statically extracted/
|
|
}
|
|
]
|
|
}]; |