mirror of
https://github.com/harness/drone.git
synced 2025-05-02 13:40:22 +00:00
168 lines
4.0 KiB
JavaScript
168 lines
4.0 KiB
JavaScript
const path = require('path');
|
|
|
|
const webpack = require('webpack')
|
|
const {
|
|
container: { ModuleFederationPlugin },
|
|
DefinePlugin
|
|
} = require('webpack');
|
|
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
|
|
const TsconfigPathsPlugin = require('tsconfig-paths-webpack-plugin');
|
|
const GenerateStringTypesPlugin = require('../scripts/webpack/GenerateStringTypesPlugin').GenerateStringTypesPlugin
|
|
const { RetryChunkLoadPlugin } = require('webpack-retry-chunk-load-plugin')
|
|
|
|
const moduleFederationConfig = require('./moduleFederation.config');
|
|
const CONTEXT = process.cwd();
|
|
|
|
const DEV = process.env.NODE_ENV === 'development'
|
|
const ON_PREM = `${process.env.ON_PREM}` === 'true'
|
|
|
|
module.exports = {
|
|
target: 'web',
|
|
context: CONTEXT,
|
|
stats: {
|
|
modules: false,
|
|
children: false
|
|
},
|
|
output: {
|
|
publicPath: 'auto',
|
|
filename: DEV ? 'static/[name].js' : 'static/[name].[contenthash:6].js',
|
|
chunkFilename: DEV ? 'static/[name].[id].js' : 'static/[name].[id].[contenthash:6].js',
|
|
pathinfo: false
|
|
},
|
|
module: {
|
|
rules: [
|
|
{
|
|
test: /\.m?js$/,
|
|
include: /node_modules/,
|
|
type: 'javascript/auto'
|
|
},
|
|
{
|
|
test: /\.(j|t)sx?$/,
|
|
exclude: /node_modules/,
|
|
use: [
|
|
{
|
|
loader: 'ts-loader',
|
|
options: {
|
|
transpileOnly: true
|
|
}
|
|
}
|
|
]
|
|
},
|
|
{
|
|
test: /\.module\.scss$/,
|
|
exclude: /node_modules/,
|
|
use: [
|
|
MiniCssExtractPlugin.loader,
|
|
{
|
|
loader: '@harness/css-types-loader',
|
|
options: {
|
|
prettierConfig: CONTEXT
|
|
}
|
|
},
|
|
{
|
|
loader: 'css-loader',
|
|
options: {
|
|
importLoaders: 1,
|
|
modules: {
|
|
mode: 'local',
|
|
localIdentName: DEV ? '[name]_[local]_[hash:base64:6]' : '[hash:base64:6]',
|
|
exportLocalsConvention: 'camelCaseOnly'
|
|
}
|
|
}
|
|
},
|
|
{
|
|
loader: 'sass-loader',
|
|
options: {
|
|
sassOptions: {
|
|
includePaths: [path.join(CONTEXT, 'src')]
|
|
},
|
|
sourceMap: false,
|
|
implementation: require('sass')
|
|
}
|
|
}
|
|
]
|
|
},
|
|
{
|
|
test: /(?<!\.module)\.scss$/,
|
|
exclude: /node_modules/,
|
|
use: [
|
|
MiniCssExtractPlugin.loader,
|
|
{
|
|
loader: 'css-loader',
|
|
options: {
|
|
importLoaders: 1,
|
|
modules: false
|
|
}
|
|
},
|
|
{
|
|
loader: 'sass-loader',
|
|
options: {
|
|
sassOptions: {
|
|
includePaths: [path.join(CONTEXT, 'src')]
|
|
},
|
|
implementation: require('sass')
|
|
}
|
|
}
|
|
]
|
|
},
|
|
{
|
|
test: /\.(jpg|jpeg|png|svg|gif)$/,
|
|
use: [
|
|
{
|
|
loader: 'url-loader',
|
|
options: {
|
|
limit: 2000,
|
|
fallback: 'file-loader'
|
|
}
|
|
}
|
|
]
|
|
},
|
|
{
|
|
test: /\.css$/,
|
|
use: ['style-loader', 'css-loader']
|
|
},
|
|
{
|
|
test: /\.ttf$/,
|
|
loader: 'file-loader'
|
|
},
|
|
{
|
|
test: /\.ya?ml$/,
|
|
type: 'json',
|
|
use: [
|
|
{
|
|
loader: 'yaml-loader'
|
|
}
|
|
]
|
|
},
|
|
{
|
|
test: /\.gql$/,
|
|
type: 'asset/source'
|
|
},
|
|
{
|
|
test: /\.(mp4)$/,
|
|
use: [
|
|
{
|
|
loader: 'file-loader'
|
|
}
|
|
]
|
|
}
|
|
]
|
|
},
|
|
resolve: {
|
|
extensions: ['.mjs', '.js', '.ts', '.tsx', '.json', '.ttf', '.scss'],
|
|
plugins: [
|
|
new TsconfigPathsPlugin()]
|
|
},
|
|
plugins: [
|
|
new ModuleFederationPlugin(moduleFederationConfig),
|
|
new DefinePlugin({
|
|
'process.env': '{}', // required for @blueprintjs/core
|
|
__DEV__: DEV,
|
|
__ON_PREM__: ON_PREM
|
|
}),
|
|
new GenerateStringTypesPlugin(),
|
|
new RetryChunkLoadPlugin({
|
|
maxRetries: 2
|
|
}),
|
|
]
|
|
}; |