Simplify building script

This commit is contained in:
2026-05-02 11:31:16 +02:00
parent 0cc7fc336a
commit da46106779
7 changed files with 105 additions and 307 deletions

102
build/webpack.config.js Normal file
View File

@@ -0,0 +1,102 @@
const path = require('path');
const webpack = require('webpack');
const CopyWebpackPlugin = require('copy-webpack-plugin');
const { CleanWebpackPlugin } = require('clean-webpack-plugin');
const SymlinkWebpackPlugin = require('symlink-webpack-plugin');
const { VueLoaderPlugin } = require('vue-loader');
const ROOT = path.resolve(__dirname, '..');
const SRC = path.resolve(ROOT, 'src');
const DIST = path.resolve(ROOT, 'dist');
const LIB = path.resolve(ROOT, 'lib');
module.exports = (env, argv) => {
const mode = argv.mode || 'production';
const isDev = (mode === 'development');
return {
mode,
devtool: isDev ? 'inline-source-map' : false,
watch: isDev,
entry: {
app: path.resolve(SRC, 'scripts', 'app.js')
},
output: {
path: DIST,
filename: '[name].js',
publicPath: '../dist/'
},
module: {
rules: [{
test: /\.vue$/,
loader: 'vue-loader'
}, {
test: /\.js$/,
exclude: file => (/node_modules/.test(file) && !/\.vue\.js/.test(file)),
use: {
loader: 'babel-loader',
options: {
presets: ['@babel/preset-env']
}
}
}, {
test: /\.html$/i,
loader: 'html-loader'
}, {
test: /\.s[ac]ss$/i,
use: [
'vue-style-loader',
'css-loader',
{
loader: 'sass-loader',
options: {
implementation: require.resolve('sass'),
sourceMap: isDev
}
}
]
}, {
test: /\.css$/i,
use: ['vue-style-loader', 'css-loader']
}, {
test: /\.(png|svg|jpg|jpeg|gif)$/i,
type: 'asset',
parser: {
dataUrlCondition: {
maxSize: 1 * 1024
}
},
generator: {
filename: 'images/[name][ext]'
}
}]
},
plugins: [
new CopyWebpackPlugin({
patterns: [
{ from: path.resolve(LIB, 'index.php'), to: 'index.php' },
{ from: path.resolve(SRC, 'images', 'logo_black.png'), to: 'images' },
{ from: path.resolve(SRC, 'images', 'spot-logo-only.svg'), to: 'images' }
]
}),
new SymlinkWebpackPlugin([
{ origin: '../files/', symlink: 'files' },
{ origin: '../geo/', symlink: 'geo' },
{ origin: '../src/images/icons/', symlink: 'images/icons' }
]),
new CleanWebpackPlugin(),
new webpack.DefinePlugin({
__VUE_OPTIONS_API__: 'true',
__VUE_PROD_DEVTOOLS__: 'false',
__VUE_PROD_HYDRATION_MISMATCH_DETAILS__: 'false'
}),
new VueLoaderPlugin()
],
resolve: {
extensions: ['.js', '.vue', '...'],
alias: {
'@scripts': path.resolve(SRC, 'scripts')
}
}
};
};