2019-10-14 16:00:50 +02:00
|
|
|
const path = require("path");
|
|
|
|
|
const createIndexMiddleware = require("./middleware/IndexMiddleware");
|
|
|
|
|
const createContextPathMiddleware = require("./middleware/ContextPathMiddleware");
|
|
|
|
|
|
|
|
|
|
const root = path.resolve(process.cwd(), "scm-ui");
|
|
|
|
|
|
|
|
|
|
module.exports = [
|
|
|
|
|
{
|
|
|
|
|
context: root,
|
|
|
|
|
entry: {
|
2019-10-23 10:13:53 +02:00
|
|
|
webapp: [
|
|
|
|
|
path.resolve(__dirname, "webpack-public-path.js"),
|
|
|
|
|
"./ui-styles/src/scm.scss",
|
|
|
|
|
"./ui-webapp/src/index.tsx"
|
|
|
|
|
]
|
2019-10-14 16:00:50 +02:00
|
|
|
},
|
|
|
|
|
devtool: "cheap-module-eval-source-map",
|
|
|
|
|
target: "web",
|
|
|
|
|
node: {
|
|
|
|
|
fs: "empty",
|
|
|
|
|
net: "empty",
|
|
|
|
|
tls: "empty"
|
|
|
|
|
},
|
|
|
|
|
module: {
|
|
|
|
|
rules: [
|
|
|
|
|
{
|
|
|
|
|
parser: {
|
|
|
|
|
system: false,
|
|
|
|
|
systemjs: false
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
{
|
2019-10-19 16:38:07 +02:00
|
|
|
test: /\.(js|ts|jsx|tsx)$/i,
|
2019-10-14 16:00:50 +02:00
|
|
|
exclude: /node_modules/,
|
|
|
|
|
use: [
|
|
|
|
|
{
|
|
|
|
|
loader: "cache-loader"
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
loader: "thread-loader"
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
loader: "babel-loader",
|
|
|
|
|
options: {
|
|
|
|
|
cacheDirectory: true,
|
|
|
|
|
presets: ["@scm-manager/babel-preset"]
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
]
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
test: /\.(css|scss|sass)$/i,
|
|
|
|
|
use: [
|
|
|
|
|
// Creates `style` nodes from JS strings
|
|
|
|
|
"style-loader",
|
|
|
|
|
// Translates CSS into CommonJS
|
|
|
|
|
"css-loader",
|
|
|
|
|
// Compiles Sass to CSS
|
|
|
|
|
"sass-loader"
|
|
|
|
|
]
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
test: /\.(png|svg|jpg|gif|woff2?|eot|ttf)$/,
|
|
|
|
|
use: ["file-loader"]
|
|
|
|
|
}
|
|
|
|
|
]
|
|
|
|
|
},
|
2019-10-19 16:38:07 +02:00
|
|
|
resolve: {
|
2019-10-21 14:52:08 +02:00
|
|
|
extensions: [".ts", ".tsx", ".js", ".jsx", ".css", ".scss", ".json"]
|
2019-10-19 16:38:07 +02:00
|
|
|
},
|
2019-10-14 16:00:50 +02:00
|
|
|
output: {
|
|
|
|
|
path: path.join(root, "target", "assets"),
|
|
|
|
|
filename: "[name].bundle.js"
|
|
|
|
|
},
|
|
|
|
|
devServer: {
|
|
|
|
|
contentBase: path.join(root, "ui-webapp", "public"),
|
|
|
|
|
compress: false,
|
|
|
|
|
historyApiFallback: true,
|
|
|
|
|
overlay: true,
|
|
|
|
|
port: 3000,
|
|
|
|
|
before: function(app) {
|
|
|
|
|
app.use(createContextPathMiddleware("/scm"));
|
|
|
|
|
},
|
|
|
|
|
after: function(app) {
|
2019-10-21 14:52:08 +02:00
|
|
|
const templatePath = path.join(root, "ui-webapp", "public", "index.mustache");
|
2019-10-14 16:00:50 +02:00
|
|
|
const renderParams = {
|
|
|
|
|
contextPath: "/scm"
|
|
|
|
|
};
|
|
|
|
|
app.use(createIndexMiddleware(templatePath, renderParams));
|
|
|
|
|
},
|
|
|
|
|
publicPath: "/assets/"
|
|
|
|
|
},
|
|
|
|
|
optimization: {
|
|
|
|
|
runtimeChunk: "single",
|
|
|
|
|
splitChunks: {
|
|
|
|
|
chunks: "all",
|
|
|
|
|
cacheGroups: {
|
|
|
|
|
vendors: {
|
|
|
|
|
test: /[\\/]node_modules[\\/]/,
|
|
|
|
|
priority: -10
|
|
|
|
|
// chunks: chunk => chunk.name !== "polyfill"
|
|
|
|
|
},
|
|
|
|
|
default: {
|
|
|
|
|
minChunks: 2,
|
|
|
|
|
priority: -20,
|
|
|
|
|
reuseExistingChunk: true
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
context: path.resolve(root),
|
|
|
|
|
entry: {
|
|
|
|
|
polyfills: "./ui-polyfill/src/index.js"
|
|
|
|
|
},
|
|
|
|
|
output: {
|
|
|
|
|
path: path.resolve(root, "target", "assets"),
|
|
|
|
|
filename: "[name].bundle.js"
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
];
|