Files
SCM-Manager/scm-ui/scripts/webpack.config.js

123 lines
2.7 KiB
JavaScript
Raw Normal View History

2019-10-07 10:57:09 +02:00
const path = require("path");
2019-10-07 17:06:00 +02:00
const createIndexMiddleware = require("./IndexMiddleware");
const createContextPathMiddleware = require("./ContextPathMiddleware");
2019-10-07 10:57:09 +02:00
module.exports = [{
2019-10-07 10:57:09 +02:00
context: path.resolve(__dirname, ".."),
entry: {
2019-10-07 17:06:00 +02:00
webapp: [
"./ui-webapp/src/webpack-public-path.js",
"./ui-styles/src/scm.scss",
2019-10-07 17:06:00 +02:00
"./ui-webapp/src/index.js"
]
2019-10-07 10:57:09 +02:00
},
2019-10-08 16:01:31 +02:00
devtool: "cheap-module-eval-source-map",
2019-10-07 10:57:09 +02:00
target: "web",
node: {
fs: "empty",
net: "empty",
tls: "empty"
},
module: {
rules: [
{
parser: {
system: false,
systemjs: false
}
},
{
test: /\.(js|jsx)$/,
2019-10-08 16:01:31 +02:00
exclude: /node_modules/,
use: [
{
loader: "cache-loader"
},
{
loader: "thread-loader"
},
{
loader: "babel-loader",
options: {
cacheDirectory: true,
presets: [
2019-10-10 10:53:38 +02:00
"@scm-manager/babel-preset"
]
}
2019-10-07 10:57:09 +02:00
}
]
2019-10-07 10:57:09 +02:00
},
{
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"]
}
]
},
output: {
2019-10-08 08:36:53 +02:00
path: path.resolve(__dirname, "..", "target", "assets"),
2019-10-07 10:57:09 +02:00
filename: "[name].bundle.js"
2019-10-07 17:06:00 +02:00
},
devServer: {
2019-10-08 16:01:31 +02:00
contentBase: path.join(__dirname, "..", "ui-webapp", "public"),
compress: false,
2019-10-07 17:06:00 +02:00
historyApiFallback: true,
overlay: true,
port: 3000,
before: function(app) {
app.use(createContextPathMiddleware("/scm"));
},
after: function(app) {
const templatePath = path.join(
__dirname,
"..",
"ui-webapp",
"public",
"index.mustache"
);
2019-10-07 17:06:00 +02:00
const renderParams = {
contextPath: "/scm"
};
app.use(createIndexMiddleware(templatePath, renderParams));
},
2019-10-08 16:01:31 +02:00
publicPath: "/assets/"
},
optimization: {
runtimeChunk: "single",
splitChunks: {
chunks: "all",
2019-10-08 16:01:31 +02:00
cacheGroups: {
vendors: {
2019-10-08 16:01:31 +02:00
test: /[\\/]node_modules[\\/]/,
priority: -10,
// chunks: chunk => chunk.name !== "polyfill"
},
default: {
minChunks: 2,
priority: -20,
reuseExistingChunk: true
2019-10-08 16:01:31 +02:00
}
}
}
2019-10-07 10:57:09 +02:00
}
}, {
context: path.resolve(__dirname, ".."),
entry: {
2019-10-11 14:26:57 +02:00
polyfills: "./ui-polyfill/src/index.js"
},
output: {
path: path.resolve(__dirname, "..", "target", "assets"),
filename: "[name].bundle.js"
}
}];