You've already forked bsl_console
mirror of
https://github.com/salexdv/bsl_console.git
synced 2025-09-16 09:06:17 +02:00
Conf webpack #18
This commit is contained in:
47
package.json
Normal file
47
package.json
Normal file
@@ -0,0 +1,47 @@
|
||||
{
|
||||
"name": "bsl-console",
|
||||
"version": "1.0.0",
|
||||
"description": "",
|
||||
"main": "editor.js",
|
||||
"homepage": "https://github.com/salexdv/bsl_console",
|
||||
"scripts": {
|
||||
"test": "mocha",
|
||||
"debug": "webpack-dev-server --mode development --progress",
|
||||
"build": "webpack --mode production --progress"
|
||||
},
|
||||
"author": "Shkuraev Alexander",
|
||||
"license": "MIT",
|
||||
"devDependencies": {
|
||||
"@babel/core": "^7.0.0",
|
||||
"@babel/preset-env": "^7.0.0",
|
||||
"autoprefixer": "^9.8.6",
|
||||
"babel-loader": "^8.1.0",
|
||||
"babel-preset-es2015": "^6.24.1",
|
||||
"babel-upgrade": "^1.0.1",
|
||||
"base64-inline-loader": "^1.1.1",
|
||||
"chai": "^4.3.4",
|
||||
"clean-webpack-plugin": "^3.0.0",
|
||||
"css-loader": "^4.3.0",
|
||||
"file-loader": "^6.1.0",
|
||||
"html-webpack-plugin": "^4.4.1",
|
||||
"mocha": "^9.0.0",
|
||||
"monaco-editor-esm-webpack-plugin": "^2.0.0",
|
||||
"postcss-cli": "^8.2.0",
|
||||
"postcss-loader": "^3.0.0",
|
||||
"remove-files-webpack-plugin": "^1.4.5",
|
||||
"script-ext-html-webpack-plugin": "^2.1.5",
|
||||
"style-loader": "^1.2.1",
|
||||
"terser-webpack-plugin": "^5.1.3",
|
||||
"ttf-loader": "^1.0.2",
|
||||
"uglifyjs-webpack-plugin": "^2.2.0",
|
||||
"webpack": "^4.43.0",
|
||||
"webpack-cli": "^3.3.11",
|
||||
"webpack-dev-server": "^3.11.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"monaco-editor": "^0.20.0",
|
||||
"monaco-editor-nls": "^2.0.0",
|
||||
"monaco-editor-webpack-plugin": "^1.9.0",
|
||||
"string-replace-loader": "^3.0.2"
|
||||
}
|
||||
}
|
10
postcss.config.js
Normal file
10
postcss.config.js
Normal file
@@ -0,0 +1,10 @@
|
||||
const autoprefixer = require('autoprefixer')
|
||||
|
||||
module.exports = {
|
||||
plugins: [
|
||||
autoprefixer({
|
||||
overrideBrowserslist: ['ie >= 8', 'last 4 version'],
|
||||
extensions: ['.css']
|
||||
})
|
||||
]
|
||||
}
|
196
webpack.config.js
Normal file
196
webpack.config.js
Normal file
@@ -0,0 +1,196 @@
|
||||
const MonacoWebpackPlugin = require('monaco-editor-esm-webpack-plugin');
|
||||
const HtmlWebpackPlugin = require('html-webpack-plugin');
|
||||
const ScriptExtHtmlWebpackPlugin = require('script-ext-html-webpack-plugin');
|
||||
const { CleanWebpackPlugin } = require("clean-webpack-plugin");
|
||||
const RemovePlugin = require('remove-files-webpack-plugin');
|
||||
const webpack = require('webpack');
|
||||
const path = require('path');
|
||||
|
||||
module.exports = (env, args) => {
|
||||
|
||||
return {
|
||||
context: path.resolve(__dirname, 'src'),
|
||||
entry: Object.assign(
|
||||
{
|
||||
console: './editor'
|
||||
},
|
||||
args.mode == 'development' ?
|
||||
{
|
||||
test: './test',
|
||||
test_query: './test_query'
|
||||
}
|
||||
: {}
|
||||
),
|
||||
output: {
|
||||
path: path.resolve(__dirname, 'dist'),
|
||||
filename: '[name].js'
|
||||
},
|
||||
resolveLoader: {
|
||||
alias: {
|
||||
'blob-url-loader': require.resolve('./tools/loaders/blobUrl'),
|
||||
'compile-loader': require.resolve('./tools/loaders/compile'),
|
||||
}
|
||||
},
|
||||
devtool: args.mode == 'development' ? "inline-source-map" : false,
|
||||
module: {
|
||||
rules: [
|
||||
args.customOptions ?
|
||||
{
|
||||
test: /src[\\/]editor\.js$/,
|
||||
loader: 'string-replace-loader',
|
||||
options: {
|
||||
search: 'customOptions: true',
|
||||
replace: args.customOptions + ', customOptions: true'
|
||||
}
|
||||
} : {},
|
||||
{
|
||||
test: /node_modules[\\/]monaco-editor[\\/].+actions\.js$/,
|
||||
loader: 'string-replace-loader',
|
||||
options: {
|
||||
search: '(this._menuItems.get(id) || []).slice(0);',
|
||||
replace: '(this._menuItems.get(id) || []).slice(0);result=result.filter(function(item){return isIMenuItem(item)&&item.command.id.indexOf("_bsl")>=0;});'
|
||||
}
|
||||
},
|
||||
{
|
||||
test: /node_modules[\\/]monaco-editor[\\/].+standaloneEnums\.js$/,
|
||||
loader: 'string-replace-loader',
|
||||
options: {
|
||||
search: '108] = "NUMPAD_DIVIDE"',
|
||||
replace: '108] = "/"'
|
||||
}
|
||||
},
|
||||
{
|
||||
test: /node_modules[\\/]monaco-editor[\\/].+parameterHintsWidget\.js$/,
|
||||
loader: 'string-replace-loader',
|
||||
options: {
|
||||
multiple: [{
|
||||
search: 'var $ = dom.$;',
|
||||
replace: "import { escapeRegExpCharacters } from '../../../base/common/strings.js'; var $ = dom.$;"
|
||||
},
|
||||
{
|
||||
search: /var idx = signature\.label\.[\s\S.]*];/im,
|
||||
replace: 'if (!param.label.length) { return [0, 0]; } else { var regex = new RegExp("(\\\\W|^)${escapeRegExpCharacters(param.label)}(?=\\\\W|$)", "g"); regex.test(signature.label); var idx = regex.lastIndex - param.label.length; return idx >= 0 ? [idx, regex.lastIndex] : [0, 0]; }'
|
||||
}]
|
||||
|
||||
}
|
||||
},
|
||||
{
|
||||
test: /node_modules[\\/]monaco-editor[\\/].+parameterHints\.js$/,
|
||||
loader: 'string-replace-loader',
|
||||
options: {
|
||||
multiple: [{
|
||||
search: '[512 /* Alt */ | 16 /* UpArrow */',
|
||||
replace: '[2048 /* CtrlCmd */ | 16 /* UpArrow */'
|
||||
},
|
||||
{
|
||||
search: '[512 /* Alt */ | 18 /* DownArrow */',
|
||||
replace: '[2048 /* CtrlCmd */ | 18 /* DownArrow */'
|
||||
}]
|
||||
|
||||
}
|
||||
},
|
||||
{
|
||||
test: /node_modules[\\/]monaco-editor-nls[\\/].+\.js$/,
|
||||
loader: 'string-replace-loader',
|
||||
options: {
|
||||
multiple: [{
|
||||
search: 'let CURRENT_LOCALE_DATA = null;',
|
||||
replace: 'var CURRENT_LOCALE_DATA = null;'
|
||||
}]
|
||||
}
|
||||
},
|
||||
{
|
||||
test: /node_modules[\\/]monaco-editor[\\/]esm[\\/].+\.js$/,
|
||||
loader: 'string-replace-loader',
|
||||
options: {
|
||||
multiple: [{
|
||||
search: 'let __insane_func;',
|
||||
replace: 'var __insane_func;'
|
||||
}]
|
||||
}
|
||||
},
|
||||
{
|
||||
test: /\.ttf$/,
|
||||
use: 'base64-inline-loader?limit=1000&name=[name].[ext]'
|
||||
},
|
||||
{
|
||||
test: /\.js/,
|
||||
enforce: 'pre',
|
||||
include: /node_modules[\\\/]monaco-editor[\\\/]esm/,
|
||||
use: MonacoWebpackPlugin.loader
|
||||
},
|
||||
{
|
||||
test: /\.js$/,
|
||||
exclude: /node_modules/,
|
||||
use: {
|
||||
loader: 'babel-loader',
|
||||
options: {
|
||||
cacheDirectory: true,
|
||||
presets: ['@babel/env']
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
test: /\.css$/,
|
||||
use: [
|
||||
'style-loader',
|
||||
'css-loader',
|
||||
'postcss-loader'
|
||||
]
|
||||
},
|
||||
]
|
||||
},
|
||||
optimization: {
|
||||
minimize: args.mode === 'production',
|
||||
splitChunks: {
|
||||
chunks: 'all'
|
||||
}
|
||||
},
|
||||
plugins: [
|
||||
new MonacoWebpackPlugin({
|
||||
languages: ['xml'],
|
||||
}),
|
||||
args.mode == 'production' ? new webpack.optimize.LimitChunkCountPlugin({
|
||||
maxChunks: 10
|
||||
}) : false,
|
||||
new CleanWebpackPlugin(),
|
||||
new HtmlWebpackPlugin({
|
||||
inject: 'body',
|
||||
chunks: ['console'],
|
||||
template: './index.html',
|
||||
filename: 'index.html',
|
||||
cache: false
|
||||
}),
|
||||
args.mode == 'production' ? new ScriptExtHtmlWebpackPlugin({
|
||||
inline: ['console.js']
|
||||
}) : false,
|
||||
args.mode == 'development' ? new HtmlWebpackPlugin({
|
||||
inject: 'body',
|
||||
chunks: ['console', 'test'],
|
||||
template: './test.html',
|
||||
filename: 'test',
|
||||
cache: false
|
||||
}) : false,
|
||||
args.mode == 'development' ? new HtmlWebpackPlugin({
|
||||
inject: 'body',
|
||||
chunks: ['console', 'test_query'],
|
||||
template: './test_query.html',
|
||||
filename: 'test_query',
|
||||
cache: false
|
||||
}) : false,
|
||||
args.mode == 'production' ? new RemovePlugin({
|
||||
after: {
|
||||
include: [
|
||||
'./dist/test.js',
|
||||
'./dist/test_query.js',
|
||||
'./dist/editor.worker.js'
|
||||
]
|
||||
}
|
||||
}) : false
|
||||
].filter(Boolean),
|
||||
devServer: {
|
||||
port: 9000,
|
||||
open: true
|
||||
}
|
||||
}
|
||||
};
|
Reference in New Issue
Block a user