-
Notifications
You must be signed in to change notification settings - Fork 134
/
webpack.config.js
75 lines (68 loc) · 2.24 KB
/
webpack.config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
'use strict';
const path = require('path');
const MonacoWebpackPlugin = require('monaco-editor-webpack-plugin');
const RIG_BASE_PATH = path.dirname(require.resolve('@rushstack/heft-web-rig/package.json'));
/**
* require.resolve() an importPath using another NPM package's folder as
* the base directory for module resolution
*/
function getPackagePathRelativeToRig(importPath) {
const targetPath = require.resolve(importPath, { paths: [RIG_BASE_PATH] });
return targetPath;
}
/**
* require() an importPath using another NPM package's folder as
* the base directory for module resolution
*/
function requireRelativeToRig(importPath) {
const targetPath = getPackagePathRelativeToRig(importPath);
return require(targetPath);
}
const createWebpackConfig = require('@rushstack/heft-web-rig/profiles/app/webpack-base.config');
const webpack = requireRelativeToRig('webpack');
const HtmlWebpackPlugin = requireRelativeToRig('html-webpack-plugin');
module.exports = function createConfig(env, argv) {
return createWebpackConfig({
env: env,
argv: argv,
projectRoot: __dirname,
// Documentation: https://webpack.js.org/configuration/
configOverride: {
module: {
rules: [
{
// For the lib/samples files which are imported as source code
test: /\.ts$/,
type: 'asset/source'
},
// The following rules are needed to support the Monaco Editor
{
test: /\.css$/,
use: [getPackagePathRelativeToRig('style-loader'), getPackagePathRelativeToRig('css-loader')],
include: /node_modules[\/\\]monaco-editor/
},
{
test: /\.ttf$/,
type: 'asset/resource',
include: /node_modules[\/\\]monaco-editor/
}
]
},
plugins: [
new HtmlWebpackPlugin({
inject: true,
template: `handlebars-loader!${__dirname}/public/index.hbs`,
chunks: {}
}),
new webpack.optimize.ModuleConcatenationPlugin(),
new webpack.DefinePlugin({
COMMIT_ID: `'${process.env['BUILD_SOURCEVERSION'] || 'COMMIT_SHA'}'`
}),
new MonacoWebpackPlugin()
],
performance: {
hints: false
}
}
});
};