mirror of
https://github.com/Eugeny/tabby-web.git
synced 2026-08-18 15:26:04 +01:00
.
This commit is contained in:
73
frontend/webpack.config.js
Normal file
73
frontend/webpack.config.js
Normal file
@@ -0,0 +1,73 @@
|
||||
require('dotenv').config()
|
||||
const baseConfig = require('./webpack.config.base.js')
|
||||
const fs = require('fs')
|
||||
const path = require('path')
|
||||
const { AngularWebpackPlugin } = require('@ngtools/webpack')
|
||||
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin
|
||||
const HtmlWebpackPlugin = require('html-webpack-plugin')
|
||||
|
||||
const htmlPluginOptions = {
|
||||
hash: true,
|
||||
minify: false
|
||||
}
|
||||
|
||||
const outputPath = path.join(__dirname, 'build')
|
||||
const backendURL = process.env.BACKEND_URL
|
||||
|
||||
if (process.env.DEV && !backendURL) {
|
||||
backendURL = 'http://localhost:8001'
|
||||
}
|
||||
|
||||
if (!backendURL) {
|
||||
throw new Error('BACKEND_URL env var is required')
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
name: 'browser',
|
||||
target: 'web',
|
||||
...baseConfig,
|
||||
entry: {
|
||||
index: path.resolve(__dirname, 'src/index.ts'),
|
||||
terminal: path.resolve(__dirname, 'src/terminal.ts'),
|
||||
},
|
||||
plugins: [
|
||||
...baseConfig.plugins,
|
||||
new AngularWebpackPlugin({
|
||||
tsconfig: 'tsconfig.json',
|
||||
directTemplateLoading: false,
|
||||
skipCodeGeneration: false,
|
||||
}),
|
||||
new HtmlWebpackPlugin({
|
||||
template: './src/index.html',
|
||||
filename: 'index.html',
|
||||
chunks: ['index'],
|
||||
...htmlPluginOptions,
|
||||
}),
|
||||
new HtmlWebpackPlugin({
|
||||
template: './src/terminal.html',
|
||||
filename: 'terminal.html',
|
||||
chunks: ['terminal'],
|
||||
...htmlPluginOptions,
|
||||
}),
|
||||
{
|
||||
apply: (compiler) => {
|
||||
compiler.hooks.afterEmit.tap('AfterEmitPlugin', () => {
|
||||
fs.writeFileSync(path.join(outputPath, 'config.json'), JSON.stringify({
|
||||
backendURL,
|
||||
}))
|
||||
})
|
||||
},
|
||||
},
|
||||
],
|
||||
output: {
|
||||
path: outputPath,
|
||||
pathinfo: true,
|
||||
publicPath: '/',
|
||||
filename: '[name].js',
|
||||
chunkFilename: '[name].bundle.js',
|
||||
},
|
||||
}
|
||||
|
||||
if (process.env.BUNDLE_ANALYZER) {
|
||||
module.exports[0].plugins.push(new BundleAnalyzerPlugin())
|
||||
}
|
||||
Reference in New Issue
Block a user