mirror of
https://github.com/Eugeny/tabby-web.git
synced 2026-08-18 15:26:04 +01:00
.
This commit is contained in:
77
webpack.base.config.js
Normal file
77
webpack.base.config.js
Normal file
@@ -0,0 +1,77 @@
|
|||||||
|
const webpack = require('webpack')
|
||||||
|
const HtmlWebpackPlugin = require('html-webpack-plugin')
|
||||||
|
const MiniCssExtractPlugin = require("mini-css-extract-plugin")
|
||||||
|
|
||||||
|
const htmlPluginOptions = {
|
||||||
|
hash: true,
|
||||||
|
minify: false
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
mode: process.env.DEV ? 'development' : 'production',
|
||||||
|
context: __dirname,
|
||||||
|
devtool: 'source-map',
|
||||||
|
cache: !process.env.DEV ? false : {
|
||||||
|
type: 'filesystem',
|
||||||
|
},
|
||||||
|
resolve: {
|
||||||
|
mainFields: ['esm2015', 'browser', 'module', 'main'],
|
||||||
|
modules: [
|
||||||
|
'src/',
|
||||||
|
'node_modules/',
|
||||||
|
],
|
||||||
|
extensions: ['.ts', '.js'],
|
||||||
|
},
|
||||||
|
module: {
|
||||||
|
rules: [
|
||||||
|
{
|
||||||
|
test: /\.[jt]sx?$/,
|
||||||
|
loader: '@ngtools/webpack',
|
||||||
|
},
|
||||||
|
{ test: /tabby\/app\/dist/, use: ['script-loader'] },
|
||||||
|
{
|
||||||
|
test: /\.pug$/,
|
||||||
|
use: ['apply-loader', 'pug-loader'],
|
||||||
|
include: /component\.pug/
|
||||||
|
},
|
||||||
|
{
|
||||||
|
test: /\.scss$/,
|
||||||
|
use: ['@tabby-gang/to-string-loader', 'css-loader', 'sass-loader'],
|
||||||
|
include: /component\.scss/
|
||||||
|
},
|
||||||
|
{
|
||||||
|
test: /\.scss$/,
|
||||||
|
use: [MiniCssExtractPlugin.loader, 'css-loader', 'sass-loader'],
|
||||||
|
exclude: /component\.scss/
|
||||||
|
},
|
||||||
|
{
|
||||||
|
test: /\.(ttf|eot|otf|woff|woff2)(\?v=[0-9]\.[0-9]\.[0-9])?$/,
|
||||||
|
type: 'asset/resource',
|
||||||
|
},
|
||||||
|
{ test: /\.css$/, use: [MiniCssExtractPlugin.loader, 'css-loader', 'sass-loader'] },
|
||||||
|
{
|
||||||
|
test: /\.(jpeg|png|svg)?$/,
|
||||||
|
type: 'asset/resource',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
test: /\.html$/,
|
||||||
|
loader: 'html-loader',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
plugins: [
|
||||||
|
new MiniCssExtractPlugin(),
|
||||||
|
new HtmlWebpackPlugin({
|
||||||
|
template: './src/index.html',
|
||||||
|
filename: 'index.html',
|
||||||
|
chunks: ['index'],
|
||||||
|
...htmlPluginOptions,
|
||||||
|
}),
|
||||||
|
new HtmlWebpackPlugin({
|
||||||
|
template: './src/terminal.html',
|
||||||
|
filename: 'terminal.html',
|
||||||
|
chunks: ['terminal'],
|
||||||
|
...htmlPluginOptions,
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
}
|
||||||
@@ -1,140 +1,33 @@
|
|||||||
|
const baseConfig = require('./webpack.base.config.js')
|
||||||
const path = require('path')
|
const path = require('path')
|
||||||
const webpack = require('webpack')
|
|
||||||
const { AngularWebpackPlugin } = require('@ngtools/webpack')
|
const { AngularWebpackPlugin } = require('@ngtools/webpack')
|
||||||
const HtmlWebpackPlugin = require('html-webpack-plugin')
|
|
||||||
const MiniCssExtractPlugin = require("mini-css-extract-plugin")
|
|
||||||
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin
|
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
const htmlPluginOptions = {
|
|
||||||
hash: true,
|
|
||||||
minify: false
|
|
||||||
}
|
|
||||||
|
|
||||||
const baseConfig = {
|
|
||||||
mode: process.env.DEV ? 'development' : 'production',
|
|
||||||
context: __dirname,
|
|
||||||
devtool: 'source-map',
|
|
||||||
cache: !process.env.DEV ? false : {
|
|
||||||
type: 'filesystem',
|
|
||||||
},
|
|
||||||
resolve: {
|
|
||||||
mainFields: ['esm2015', 'browser', 'module', 'main'],
|
|
||||||
modules: [
|
|
||||||
'src/',
|
|
||||||
'node_modules/',
|
|
||||||
],
|
|
||||||
extensions: ['.ts', '.js'],
|
|
||||||
},
|
|
||||||
module: {
|
|
||||||
rules: [
|
|
||||||
{
|
|
||||||
test: /\.[jt]sx?$/,
|
|
||||||
loader: '@ngtools/webpack',
|
|
||||||
},
|
|
||||||
{ test: /tabby\/app\/dist/, use: ['script-loader'] },
|
|
||||||
{
|
|
||||||
test: /\.pug$/,
|
|
||||||
use: ['apply-loader', 'pug-loader'],
|
|
||||||
include: /component\.pug/
|
|
||||||
},
|
|
||||||
{
|
|
||||||
test: /\.scss$/,
|
|
||||||
use: ['@tabby-gang/to-string-loader', 'css-loader', 'sass-loader'],
|
|
||||||
include: /component\.scss/
|
|
||||||
},
|
|
||||||
{
|
|
||||||
test: /\.scss$/,
|
|
||||||
use: [MiniCssExtractPlugin.loader, 'css-loader', 'sass-loader'],
|
|
||||||
exclude: /component\.scss/
|
|
||||||
},
|
|
||||||
{
|
|
||||||
test: /\.(ttf|eot|otf|woff|woff2)(\?v=[0-9]\.[0-9]\.[0-9])?$/,
|
|
||||||
type: 'asset/resource',
|
|
||||||
},
|
|
||||||
{ test: /\.css$/, use: [MiniCssExtractPlugin.loader, 'css-loader', 'sass-loader'] },
|
|
||||||
{
|
|
||||||
test: /\.(jpeg|png|svg)?$/,
|
|
||||||
type: 'asset/resource',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
test: /\.html$/,
|
|
||||||
loader: 'html-loader',
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
plugins: [
|
|
||||||
new MiniCssExtractPlugin(),
|
|
||||||
new HtmlWebpackPlugin({
|
|
||||||
template: './src/index.html',
|
|
||||||
filename: 'index.html',
|
|
||||||
chunks: ['index'],
|
|
||||||
...htmlPluginOptions,
|
|
||||||
}),
|
|
||||||
new HtmlWebpackPlugin({
|
|
||||||
template: './src/terminal.html',
|
|
||||||
filename: 'terminal.html',
|
|
||||||
chunks: ['terminal'],
|
|
||||||
...htmlPluginOptions,
|
|
||||||
}),
|
|
||||||
],
|
|
||||||
}
|
|
||||||
|
|
||||||
module.exports = [
|
|
||||||
{
|
|
||||||
name: 'browser',
|
name: 'browser',
|
||||||
target: 'web',
|
target: 'web',
|
||||||
...baseConfig,
|
...baseConfig,
|
||||||
entry: {
|
entry: {
|
||||||
index: path.resolve(__dirname, 'src/index.ts'),
|
index: path.resolve(__dirname, 'src/index.ts'),
|
||||||
terminal: path.resolve(__dirname, 'src/terminal.ts'),
|
terminal: path.resolve(__dirname, 'src/terminal.ts'),
|
||||||
},
|
},
|
||||||
plugins: [
|
plugins: [
|
||||||
...baseConfig.plugins,
|
...baseConfig.plugins,
|
||||||
new AngularWebpackPlugin({
|
new AngularWebpackPlugin({
|
||||||
tsconfig: 'tsconfig.json',
|
tsconfig: 'tsconfig.json',
|
||||||
directTemplateLoading: false,
|
directTemplateLoading: false,
|
||||||
skipCodeGeneration: false,
|
skipCodeGeneration: false,
|
||||||
}),
|
}),
|
||||||
],
|
],
|
||||||
output: {
|
output: {
|
||||||
path: path.join(__dirname, 'build'),
|
path: path.join(__dirname, 'build'),
|
||||||
pathinfo: true,
|
pathinfo: true,
|
||||||
publicPath: '/static/',
|
publicPath: '/static/',
|
||||||
filename: '[name].js',
|
filename: '[name].js',
|
||||||
chunkFilename: '[name].bundle.js',
|
chunkFilename: '[name].bundle.js',
|
||||||
},
|
},
|
||||||
},
|
}
|
||||||
{
|
|
||||||
name: 'server',
|
|
||||||
target: 'node',
|
|
||||||
...baseConfig,
|
|
||||||
entry: {
|
|
||||||
'index.server': path.resolve(__dirname, 'src/index.server.ts'),
|
|
||||||
'server': path.resolve(__dirname, 'src/server.ts'),
|
|
||||||
},
|
|
||||||
plugins: [
|
|
||||||
...baseConfig.plugins,
|
|
||||||
new AngularWebpackPlugin({
|
|
||||||
entryModule: path.resolve(__dirname, 'src/app/app.server.module`#AppServerModule'),
|
|
||||||
mainPath: path.resolve(__dirname, 'src/index.server.ts'),
|
|
||||||
tsconfig: 'tsconfig.json',
|
|
||||||
directTemplateLoading: false,
|
|
||||||
platform: 1,
|
|
||||||
skipCodeGeneration: false,
|
|
||||||
}),
|
|
||||||
],
|
|
||||||
output: {
|
|
||||||
libraryTarget: 'commonjs',
|
|
||||||
path: path.join(__dirname, 'build-server'),
|
|
||||||
pathinfo: true,
|
|
||||||
publicPath: '/static/',
|
|
||||||
filename: '[name].js',
|
|
||||||
chunkFilename: '[name].bundle.js',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
]
|
|
||||||
|
|
||||||
if (process.env.BUNDLE_ANALYZER) {
|
if (process.env.BUNDLE_ANALYZER) {
|
||||||
module.exports[0].plugins.push(new BundleAnalyzerPlugin())
|
module.exports[0].plugins.push(new BundleAnalyzerPlugin())
|
||||||
}
|
}
|
||||||
|
|||||||
32
webpack.server.config.js
Normal file
32
webpack.server.config.js
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
const baseConfig = require('./webpack.base.config.js')
|
||||||
|
const path = require('path')
|
||||||
|
const { AngularWebpackPlugin } = require('@ngtools/webpack')
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
name: 'server',
|
||||||
|
target: 'node',
|
||||||
|
...baseConfig,
|
||||||
|
entry: {
|
||||||
|
'index.server': path.resolve(__dirname, 'src/index.server.ts'),
|
||||||
|
'server': path.resolve(__dirname, 'src/server.ts'),
|
||||||
|
},
|
||||||
|
plugins: [
|
||||||
|
...baseConfig.plugins,
|
||||||
|
new AngularWebpackPlugin({
|
||||||
|
entryModule: path.resolve(__dirname, 'src/app/app.server.module`#AppServerModule'),
|
||||||
|
mainPath: path.resolve(__dirname, 'src/index.server.ts'),
|
||||||
|
tsconfig: 'tsconfig.json',
|
||||||
|
directTemplateLoading: false,
|
||||||
|
platform: 1,
|
||||||
|
skipCodeGeneration: false,
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
output: {
|
||||||
|
libraryTarget: 'commonjs',
|
||||||
|
path: path.join(__dirname, 'build-server'),
|
||||||
|
pathinfo: true,
|
||||||
|
publicPath: '/static/',
|
||||||
|
filename: '[name].js',
|
||||||
|
chunkFilename: '[name].bundle.js',
|
||||||
|
},
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user