focalboard/webapp/webpack.common.js

94 lines
2.8 KiB
JavaScript
Raw Normal View History

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: [
{
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
},
{
test: /\.html$/,
loader: 'file-loader',
},
{
test: /\.s[ac]ss$/i,
use: [
'style-loader',
'css-loader',
'sass-loader',
],
},
{
test: /\.(tsx?|js|jsx|html)$/,
use: [
],
exclude: [/node_modules/],
},
],
},
resolve: {
modules: [
'node_modules',
path.resolve(__dirname),
],
extensions: ['.js', '.jsx', '.ts', '.tsx'],
},
plugins: [
new CopyPlugin({
patterns: [
{from: path.resolve(__dirname, 'static'), to: 'static'},
{from: path.resolve(__dirname, 'node_modules/easymde/dist/easymde.min.css'), to: 'static'},
],
}),
new HtmlWebpackPlugin({
inject: true,
title: 'OCTO',
chunks: ['main'],
template: 'html-templates/page.ejs',
filename: 'index.html',
publicPath: '/',
}),
],
entry: {
main: './src/main.tsx',
},
output: {
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;