2020-10-20 22:26:06 +02:00
|
|
|
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
|
|
|
// See LICENSE.txt for license information.
|
2020-10-23 13:40:39 +02:00
|
|
|
const tsTransformer = require('@formatjs/ts-transformer');
|
2020-10-20 22:26:06 +02:00
|
|
|
const path = require('path');
|
|
|
|
const CopyPlugin = require('copy-webpack-plugin');
|
|
|
|
var HtmlWebpackPlugin = require('html-webpack-plugin');
|
2020-10-08 18:21:27 +02:00
|
|
|
|
2020-10-20 22:26:06 +02:00
|
|
|
const outpath = path.resolve(__dirname, 'pack');
|
2020-10-08 18:21:27 +02:00
|
|
|
|
|
|
|
function makeCommonConfig() {
|
2020-10-20 22:26:06 +02:00
|
|
|
const commonConfig = {
|
|
|
|
target: 'web',
|
|
|
|
mode: 'development',
|
|
|
|
node: {
|
|
|
|
__dirname: false,
|
|
|
|
__filename: false,
|
|
|
|
},
|
|
|
|
module: {
|
|
|
|
rules: [
|
2021-03-25 20:40:50 +02:00
|
|
|
{
|
|
|
|
test: /\.m?js/,
|
|
|
|
resolve: {
|
2021-05-26 12:44:09 +02:00
|
|
|
fullySpecified: false,
|
|
|
|
},
|
2021-03-25 20:40:50 +02:00
|
|
|
},
|
2020-10-20 22:26:06 +02:00
|
|
|
{
|
|
|
|
test: /\.tsx?$/,
|
2020-10-23 13:40:39 +02:00
|
|
|
use: {
|
|
|
|
loader: 'ts-loader',
|
|
|
|
options: {
|
|
|
|
getCustomTransformers: {
|
|
|
|
before: [
|
|
|
|
tsTransformer.transform({
|
|
|
|
overrideIdFn: '[sha512:contenthash:base64:6]',
|
|
|
|
ast: true,
|
|
|
|
}),
|
|
|
|
],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2020-10-20 22:26:06 +02:00
|
|
|
exclude: [/node_modules/],
|
2020-10-23 13:40:39 +02:00
|
|
|
|
2020-10-20 22:26:06 +02:00
|
|
|
},
|
|
|
|
{
|
2022-02-28 13:28:16 +02:00
|
|
|
test: /\.html$/,
|
2021-03-25 20:40:50 +02:00
|
|
|
type: 'asset/resource',
|
2020-10-20 22:26:06 +02:00
|
|
|
},
|
|
|
|
{
|
|
|
|
test: /\.s[ac]ss$/i,
|
|
|
|
use: [
|
|
|
|
'style-loader',
|
|
|
|
'css-loader',
|
|
|
|
'sass-loader',
|
|
|
|
],
|
|
|
|
},
|
2020-10-28 11:45:15 +02:00
|
|
|
{
|
|
|
|
test: /\.css$/i,
|
|
|
|
use: [
|
|
|
|
'style-loader',
|
|
|
|
'css-loader',
|
|
|
|
],
|
|
|
|
},
|
2020-10-20 22:26:06 +02:00
|
|
|
{
|
2021-03-25 20:40:50 +02:00
|
|
|
test: /\.(tsx?|js|jsx|mjs|html)$/,
|
2020-10-20 22:26:06 +02:00
|
|
|
use: [
|
|
|
|
],
|
|
|
|
exclude: [/node_modules/],
|
|
|
|
},
|
2021-05-26 12:44:09 +02:00
|
|
|
{
|
2022-02-28 13:28:16 +02:00
|
|
|
test: /\.(eot|tiff|svg|woff2|woff|ttf|png|jpg|jpeg|gif)$/,
|
2022-03-26 01:07:49 +02:00
|
|
|
type: 'asset/resource',
|
|
|
|
generator: {
|
|
|
|
filename: 'static/[name].[ext]',
|
|
|
|
}
|
2021-05-26 12:44:09 +02:00
|
|
|
},
|
2020-10-20 22:26:06 +02:00
|
|
|
],
|
|
|
|
},
|
|
|
|
resolve: {
|
|
|
|
modules: [
|
|
|
|
'node_modules',
|
|
|
|
path.resolve(__dirname),
|
|
|
|
],
|
2021-03-25 20:40:50 +02:00
|
|
|
fullySpecified: false,
|
2020-10-20 22:26:06 +02:00
|
|
|
extensions: ['.js', '.jsx', '.ts', '.tsx'],
|
|
|
|
},
|
|
|
|
plugins: [
|
|
|
|
new CopyPlugin({
|
|
|
|
patterns: [
|
|
|
|
{from: path.resolve(__dirname, 'static'), to: 'static'},
|
|
|
|
],
|
|
|
|
}),
|
|
|
|
new HtmlWebpackPlugin({
|
|
|
|
inject: true,
|
2021-01-27 00:32:34 +02:00
|
|
|
title: 'Focalboard',
|
2020-10-20 22:26:06 +02:00
|
|
|
chunks: ['main'],
|
|
|
|
template: 'html-templates/page.ejs',
|
|
|
|
filename: 'index.html',
|
2021-04-16 13:42:37 +02:00
|
|
|
publicPath: '{{.BaseURL}}/',
|
2021-07-20 13:18:41 +02:00
|
|
|
hash: true,
|
2020-10-20 22:26:06 +02:00
|
|
|
}),
|
|
|
|
],
|
2021-04-28 00:09:26 +02:00
|
|
|
entry: ['./src/main.tsx', './src/userSettings.ts'],
|
2020-10-20 22:26:06 +02:00
|
|
|
output: {
|
2021-04-28 00:09:26 +02:00
|
|
|
library: 'Focalboard',
|
2020-10-20 22:26:06 +02:00
|
|
|
filename: 'static/[name].js',
|
|
|
|
path: outpath,
|
|
|
|
},
|
|
|
|
};
|
2020-10-08 18:21:27 +02:00
|
|
|
|
2020-10-20 22:26:06 +02:00
|
|
|
return commonConfig;
|
2020-10-08 18:21:27 +02:00
|
|
|
}
|
|
|
|
|
2020-10-20 22:26:06 +02:00
|
|
|
module.exports = makeCommonConfig;
|