2020-01-23 00:54:02 +08:00
|
|
|
/* eslint no-undef: 0 */
|
|
|
|
|
2019-11-29 19:59:39 +08:00
|
|
|
const path = require('path');
|
|
|
|
const MiniCSSExtractPlugin = require('mini-css-extract-plugin');
|
2020-01-13 20:28:09 +08:00
|
|
|
const FixStyleOnlyEntriesPlugin = require('webpack-fix-style-only-entries');
|
|
|
|
const CopyPlugin = require('copy-webpack-plugin');
|
|
|
|
const { CleanWebpackPlugin: CleanPlugin } = require('clean-webpack-plugin');
|
2019-11-29 19:59:39 +08:00
|
|
|
|
2020-05-28 03:36:12 +08:00
|
|
|
module.exports = (env, argv) => ({
|
2019-12-05 17:34:13 +08:00
|
|
|
mode: 'development',
|
2019-11-29 19:59:39 +08:00
|
|
|
entry: {
|
2019-12-05 17:34:13 +08:00
|
|
|
"page-init": [path.join(__dirname, "src/main/js/page-init.js")],
|
2019-11-30 01:01:19 +08:00
|
|
|
"pluginSetupWizard": [
|
2019-12-05 17:34:13 +08:00
|
|
|
path.join(__dirname, "src/main/js/pluginSetupWizard.js"),
|
2019-11-30 01:01:19 +08:00
|
|
|
path.join(__dirname, "src/main/less/pluginSetupWizard.less"),
|
2020-12-08 15:29:21 +08:00
|
|
|
],
|
|
|
|
"plugin-manager-ui": [
|
|
|
|
path.join(__dirname, "src/main/js/plugin-manager-ui.js"),
|
2019-11-30 01:01:19 +08:00
|
|
|
],
|
2019-11-29 19:59:39 +08:00
|
|
|
"add-item": [
|
|
|
|
path.join(__dirname, "src/main/js/add-item.js"),
|
|
|
|
path.join(__dirname, "src/main/js/add-item.less"),
|
|
|
|
],
|
|
|
|
"config-scrollspy": [
|
|
|
|
path.join(__dirname, "src/main/js/config-scrollspy.js"),
|
|
|
|
path.join(__dirname, "src/main/js/config-scrollspy.less"),
|
|
|
|
],
|
|
|
|
"config-tabbar": [
|
|
|
|
path.join(__dirname, "src/main/js/config-tabbar.js"),
|
|
|
|
path.join(__dirname, "src/main/js/config-tabbar.less"),
|
|
|
|
],
|
2021-01-23 02:57:10 +08:00
|
|
|
"sortable-drag-drop": [path.join(__dirname, "src/main/js/sortable-drag-drop.js")],
|
2021-12-29 23:59:50 +08:00
|
|
|
"section-to-tabs": [path.join(__dirname, "src/main/js/section-to-tabs.js")],
|
2021-09-28 03:27:37 +08:00
|
|
|
"filter-build-history": [path.join(__dirname, "src/main/js/filter-build-history.js")],
|
2022-04-22 22:18:52 +08:00
|
|
|
"simple-page": [path.join(__dirname, "src/main/less/simple-page.less")],
|
2022-04-14 21:00:23 +08:00
|
|
|
"styles": [path.join(__dirname, "src/main/less/styles.less")],
|
2019-11-29 19:59:39 +08:00
|
|
|
},
|
|
|
|
output: {
|
|
|
|
path: path.join(__dirname, "src/main/webapp/jsbundles"),
|
|
|
|
},
|
2020-05-28 03:36:12 +08:00
|
|
|
devtool: argv.mode === 'production' ? 'source-map' : 'inline-cheap-module-source-map',
|
2019-11-29 19:59:39 +08:00
|
|
|
plugins: [
|
|
|
|
new FixStyleOnlyEntriesPlugin(),
|
|
|
|
new MiniCSSExtractPlugin({
|
|
|
|
filename: "[name].css",
|
|
|
|
}),
|
2020-01-13 20:28:09 +08:00
|
|
|
new CopyPlugin([
|
|
|
|
// Copies fonts to the src/main/webapp/css for compat purposes
|
|
|
|
// Some plugins or parts of the UI try to load them from these paths
|
|
|
|
{
|
|
|
|
context: 'src/main/fonts',
|
|
|
|
from: "**/*",
|
|
|
|
to: path.join(__dirname, "src/main/webapp/css")
|
|
|
|
}
|
|
|
|
]),
|
|
|
|
// Clean all assets within the specified output.
|
|
|
|
// It will not clean copied fonts
|
|
|
|
new CleanPlugin(),
|
2019-11-29 19:59:39 +08:00
|
|
|
],
|
|
|
|
module: {
|
|
|
|
rules: [
|
|
|
|
{
|
|
|
|
test: /\.(css|less)$/,
|
2020-05-28 23:34:41 +08:00
|
|
|
use: [
|
|
|
|
'style-loader',
|
2020-05-28 03:36:12 +08:00
|
|
|
{
|
|
|
|
loader: MiniCSSExtractPlugin.loader,
|
|
|
|
options: {
|
|
|
|
sourceMap: true
|
|
|
|
}
|
|
|
|
},
|
2020-02-21 00:57:47 +08:00
|
|
|
{
|
|
|
|
loader: 'css-loader',
|
|
|
|
options: {
|
2020-05-28 03:36:12 +08:00
|
|
|
sourceMap: true,
|
2020-02-21 00:57:47 +08:00
|
|
|
url: (url, resourcePath) => {
|
|
|
|
// ignore the URLS on the base styles as they are picked
|
|
|
|
// from the src/main/webapp/images dir
|
2022-04-14 21:00:23 +08:00
|
|
|
if (resourcePath.includes('styles.less')) {
|
2020-02-21 00:57:47 +08:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
2020-05-28 03:36:12 +08:00
|
|
|
{
|
|
|
|
loader: 'postcss-loader',
|
|
|
|
options: {
|
|
|
|
sourceMap: true
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
loader: 'less-loader',
|
|
|
|
options: {
|
|
|
|
sourceMap: true
|
|
|
|
}
|
|
|
|
}
|
2020-02-21 00:57:47 +08:00
|
|
|
]
|
2019-11-29 19:59:39 +08:00
|
|
|
},
|
2019-11-30 01:01:19 +08:00
|
|
|
{
|
|
|
|
test: /\.(woff(2)?|ttf|eot|svg)(\?v=\d+\.\d+\.\d+)?$/,
|
|
|
|
use: [
|
|
|
|
{
|
|
|
|
loader: 'file-loader',
|
|
|
|
options: {
|
|
|
|
name: '[name].[ext]',
|
|
|
|
outputPath: 'fonts/'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
]
|
|
|
|
},
|
2019-12-05 17:34:13 +08:00
|
|
|
{
|
|
|
|
test: /\.hbs$/,
|
|
|
|
loader: "handlebars-loader",
|
|
|
|
options: {
|
2020-01-10 20:11:44 +08:00
|
|
|
// The preferred option for adding handlebars helpers is putting them
|
|
|
|
// inside this helpers directory
|
2019-12-05 17:34:13 +08:00
|
|
|
helperDirs: path.join(__dirname, 'src/main/js/handlebars-helpers'),
|
|
|
|
precompileOptions: {
|
|
|
|
knownHelpersOnly: false,
|
|
|
|
// Helpers registered with Handlebars.registerHelper must be listed so that
|
2020-01-10 20:11:44 +08:00
|
|
|
// handlebars-loader will expect them when compiling the templates.
|
|
|
|
// This helpers cannot be moved to the helpers directory because they are closures
|
2019-12-05 17:34:13 +08:00
|
|
|
knownHelpers: [
|
|
|
|
'pluginCountForCategory',
|
|
|
|
'totalPluginCount',
|
|
|
|
'inSelectedPlugins',
|
|
|
|
'dependencyCount',
|
|
|
|
'eachDependency',
|
|
|
|
'ifVisibleDependency'
|
|
|
|
]
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
test: /\.js$/,
|
|
|
|
exclude: /node_modules/,
|
|
|
|
loader: "babel-loader",
|
|
|
|
},
|
2019-11-29 19:59:39 +08:00
|
|
|
]
|
|
|
|
},
|
|
|
|
optimization: {
|
2019-11-30 01:01:19 +08:00
|
|
|
splitChunks: {
|
2019-12-09 23:18:22 +08:00
|
|
|
chunks: 'async',
|
|
|
|
cacheGroups: {
|
|
|
|
commons: {
|
|
|
|
test: /[\\/]node_modules[\\/]/,
|
|
|
|
name: 'vendors',
|
|
|
|
chunks: 'all'
|
|
|
|
}
|
|
|
|
}
|
2019-11-30 01:01:19 +08:00
|
|
|
}
|
2019-12-05 17:34:13 +08:00
|
|
|
},
|
|
|
|
resolve: {
|
|
|
|
alias:{
|
|
|
|
// Needed to be able to register helpers at runtime
|
|
|
|
handlebars: 'handlebars/runtime',
|
|
|
|
},
|
|
|
|
},
|
2020-05-28 03:36:12 +08:00
|
|
|
});
|