mirror of
https://github.com/aleleba/create-react-ssr.git
synced 2025-06-20 04:48:30 -06:00
PR-421183: Adding Cypress and updating packages.
This commit is contained in:
@ -1,7 +1,7 @@
|
||||
import MiniCssExtractPlugin from 'mini-css-extract-plugin';
|
||||
import webpackNodeExternals from 'webpack-node-externals';
|
||||
import WebpackShellPluginNext from 'webpack-shell-plugin-next';
|
||||
import { resolveTsAliases } from "resolve-ts-aliases";
|
||||
import { resolveTsAliases } from 'resolve-ts-aliases';
|
||||
import path from 'path';
|
||||
import { Configuration } from 'webpack';
|
||||
const ROOT_DIR = path.resolve(__dirname);
|
||||
@ -11,84 +11,80 @@ const scriptExtensions = /\.(tsx|ts|js|jsx|mjs)$/;
|
||||
const styleExtensions = /\.(css|less|styl|scss|sass|sss)$/;
|
||||
const fontsExtensions = /\.(eot|otf|ttf|woff|woff2)$/;
|
||||
const fontsAndImagesExtensions = /\.(png|jpg|jpeg|gif|svg|ico|mp4|avi|ttf|otf|eot|woff|woff2|pdf)$/;
|
||||
const alias = resolveTsAliases(path.resolve("tsconfig.json"));
|
||||
const alias = resolveTsAliases(path.resolve('tsconfig.json'));
|
||||
|
||||
const config: Configuration = {
|
||||
target: 'node',
|
||||
mode: 'development',
|
||||
name: 'server',
|
||||
entry: {
|
||||
server: `${ROOT_DIR}/src/server/index.ts`,
|
||||
},
|
||||
resolve: {
|
||||
extensions: ['.js', '.jsx', '.json', '.ts', '.tsx'],
|
||||
alias,
|
||||
},
|
||||
module: {
|
||||
rules: [
|
||||
{
|
||||
test: /\.(tsx|ts)$/, loader: "ts-loader",
|
||||
exclude: /node_modules/
|
||||
},
|
||||
{
|
||||
test: scriptExtensions,
|
||||
use: {
|
||||
loader: 'babel-loader',
|
||||
},
|
||||
exclude: [/node_modules/, /src\/frontend/],
|
||||
},
|
||||
{
|
||||
// Preprocess our own style files
|
||||
test: styleExtensions,
|
||||
exclude: /node_modules/,
|
||||
use: [
|
||||
{
|
||||
loader: MiniCssExtractPlugin.loader,
|
||||
options: {
|
||||
emit: false,
|
||||
}
|
||||
},
|
||||
'css-loader',
|
||||
'sass-loader',
|
||||
target: 'node',
|
||||
mode: 'development',
|
||||
name: 'server',
|
||||
entry: {
|
||||
server: `${ROOT_DIR}/src/server/index.ts`,
|
||||
},
|
||||
resolve: {
|
||||
extensions: ['.js', '.jsx', '.json', '.ts', '.tsx'],
|
||||
alias,
|
||||
},
|
||||
module: {
|
||||
rules: [
|
||||
{
|
||||
test: scriptExtensions,
|
||||
use: {
|
||||
loader: 'babel-loader',
|
||||
},
|
||||
exclude: /node_modules/,
|
||||
},
|
||||
{
|
||||
// Preprocess our own style files
|
||||
test: styleExtensions,
|
||||
exclude: /node_modules/,
|
||||
use: [
|
||||
{
|
||||
loader: MiniCssExtractPlugin.loader,
|
||||
options: {
|
||||
emit: false,
|
||||
}
|
||||
},
|
||||
'css-loader',
|
||||
'sass-loader',
|
||||
],
|
||||
},
|
||||
{
|
||||
test: fontsAndImagesExtensions,
|
||||
loader: 'file-loader',
|
||||
},
|
||||
{
|
||||
test: fontsAndImagesExtensions,
|
||||
loader: 'file-loader',
|
||||
options: {
|
||||
name: 'assets/[name].[ext]',
|
||||
emitFile: false,
|
||||
emitFile: false,
|
||||
},
|
||||
},
|
||||
{
|
||||
test: fontsExtensions,
|
||||
loader: 'url-loader',
|
||||
},
|
||||
{
|
||||
test: fontsExtensions,
|
||||
loader: 'url-loader',
|
||||
options: {
|
||||
name: 'assets/fonts/[name].[ext]',
|
||||
esModule: false,
|
||||
},
|
||||
}
|
||||
]
|
||||
},
|
||||
output: {
|
||||
path: BUILD_DIR,
|
||||
filename: '[name].js',
|
||||
libraryTarget: 'commonjs2',
|
||||
},
|
||||
node: false,
|
||||
externals: [webpackNodeExternals()],
|
||||
plugins: [
|
||||
new MiniCssExtractPlugin({
|
||||
filename: 'assets/app.css',
|
||||
}),
|
||||
new WebpackShellPluginNext({
|
||||
}
|
||||
]
|
||||
},
|
||||
output: {
|
||||
path: BUILD_DIR,
|
||||
filename: '[name].js',
|
||||
libraryTarget: 'commonjs2',
|
||||
},
|
||||
node: false,
|
||||
externals: [webpackNodeExternals()],
|
||||
plugins: [
|
||||
new MiniCssExtractPlugin({
|
||||
filename: 'assets/app.css',
|
||||
}),
|
||||
new WebpackShellPluginNext({
|
||||
onBuildEnd: {
|
||||
scripts: ['node build/server.js'],
|
||||
blocking: false,
|
||||
parallel: true
|
||||
}
|
||||
})
|
||||
],
|
||||
],
|
||||
};
|
||||
|
||||
export default config
|
||||
export default config;
|
||||
|
Reference in New Issue
Block a user