2018-02-24 18:37:57 +01:00
|
|
|
const path = require('path');
|
|
|
|
const glob = require('glob');
|
|
|
|
|
|
|
|
// Minify JS
|
2023-05-24 11:35:15 +02:00
|
|
|
const TerserPlugin = require('terser-webpack-plugin');
|
2018-02-24 18:37:57 +01:00
|
|
|
|
|
|
|
// This plugin extracts the CSS into its own file instead of tying it with the JS.
|
|
|
|
// It prevents:
|
|
|
|
// - not having styles due to a JS error
|
|
|
|
// - the flash page without styles during JS loading
|
2023-05-24 11:35:15 +02:00
|
|
|
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
|
2018-02-24 18:37:57 +01:00
|
|
|
|
2023-05-24 11:35:15 +02:00
|
|
|
const extractCss = new MiniCssExtractPlugin({
|
2024-12-10 16:31:21 +01:00
|
|
|
filename: "css/[name].min.css",
|
2018-02-24 18:37:57 +01:00
|
|
|
});
|
|
|
|
|
|
|
|
module.exports = [
|
|
|
|
{
|
2023-05-24 11:35:15 +02:00
|
|
|
mode: 'production',
|
2018-02-24 18:37:57 +01:00
|
|
|
entry: {
|
2023-05-24 11:35:15 +02:00
|
|
|
shaare_batch: './assets/common/js/shaare-batch.js',
|
2017-11-11 14:01:21 +01:00
|
|
|
thumbnails: './assets/common/js/thumbnails.js',
|
2018-06-08 12:50:49 +02:00
|
|
|
thumbnails_update: './assets/common/js/thumbnails-update.js',
|
2023-05-24 11:35:15 +02:00
|
|
|
metadata: './assets/common/js/metadata.js',
|
2018-02-24 18:37:57 +01:00
|
|
|
pluginsadmin: './assets/default/js/plugins-admin.js',
|
|
|
|
shaarli: [
|
|
|
|
'./assets/default/js/base.js',
|
|
|
|
'./assets/default/scss/shaarli.scss',
|
2024-12-10 16:31:21 +01:00
|
|
|
].concat(glob.sync('./assets/default/img/*', { dotRelative: true })),
|
2023-05-24 11:35:15 +02:00
|
|
|
markdown: './assets/common/css/markdown.css',
|
2018-02-24 18:37:57 +01:00
|
|
|
},
|
|
|
|
output: {
|
2024-12-10 16:31:21 +01:00
|
|
|
filename: 'js/[name].min.js',
|
|
|
|
path: path.resolve(__dirname, 'tpl/default/')
|
2018-02-24 18:37:57 +01:00
|
|
|
},
|
|
|
|
module: {
|
|
|
|
rules: [
|
|
|
|
{
|
|
|
|
test: /\.js$/,
|
|
|
|
exclude: /node_modules/,
|
|
|
|
use: {
|
|
|
|
loader: 'babel-loader',
|
|
|
|
options: {
|
|
|
|
presets: [
|
2023-05-24 11:35:15 +02:00
|
|
|
'@babel/preset-env',
|
2018-02-24 18:37:57 +01:00
|
|
|
]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
2023-05-24 11:35:15 +02:00
|
|
|
test: /\.s?css/,
|
|
|
|
use: [
|
|
|
|
{
|
|
|
|
loader: MiniCssExtractPlugin.loader,
|
|
|
|
},
|
|
|
|
'css-loader',
|
|
|
|
'sass-loader',
|
|
|
|
],
|
2018-02-24 18:37:57 +01:00
|
|
|
},
|
|
|
|
{
|
|
|
|
test: /\.(gif|png|jpe?g|svg|ico)$/i,
|
2024-12-10 16:31:21 +01:00
|
|
|
type: 'asset/resource',
|
|
|
|
generator: {
|
|
|
|
filename: 'img/[name][ext]'
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
test: /webfont\.svg$/,
|
|
|
|
type: 'asset/resource',
|
|
|
|
generator: {
|
|
|
|
filename: 'fonts/[name][ext]'
|
|
|
|
}
|
2018-02-24 18:37:57 +01:00
|
|
|
},
|
|
|
|
{
|
|
|
|
test: /\.(eot|ttf|woff|woff2)(\?v=[0-9]\.[0-9]\.[0-9])?$/,
|
2024-12-10 16:31:21 +01:00
|
|
|
type: 'asset/resource',
|
|
|
|
generator: {
|
|
|
|
filename: 'fonts/[name][ext]'
|
2018-02-24 18:37:57 +01:00
|
|
|
}
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
2023-05-24 11:35:15 +02:00
|
|
|
optimization: {
|
|
|
|
minimize: true,
|
|
|
|
minimizer: [new TerserPlugin()],
|
|
|
|
},
|
2018-02-24 18:37:57 +01:00
|
|
|
plugins: [
|
2023-05-24 11:35:15 +02:00
|
|
|
extractCss,
|
2018-02-24 18:37:57 +01:00
|
|
|
],
|
|
|
|
},
|
|
|
|
{
|
2023-05-24 11:35:15 +02:00
|
|
|
mode: 'production',
|
2018-02-24 18:37:57 +01:00
|
|
|
entry: {
|
|
|
|
shaarli: [
|
|
|
|
'./assets/vintage/js/base.js',
|
|
|
|
'./assets/vintage/css/reset.css',
|
|
|
|
'./assets/vintage/css/shaarli.css',
|
2024-12-10 16:31:21 +01:00
|
|
|
].concat(glob.sync('./assets/vintage/img/*', { dotRelative: true })),
|
2023-05-24 11:35:15 +02:00
|
|
|
markdown: './assets/common/css/markdown.css',
|
2017-11-11 14:01:21 +01:00
|
|
|
thumbnails: './assets/common/js/thumbnails.js',
|
2023-05-24 11:35:15 +02:00
|
|
|
metadata: './assets/common/js/metadata.js',
|
2018-06-08 12:50:49 +02:00
|
|
|
thumbnails_update: './assets/common/js/thumbnails-update.js',
|
2018-02-24 18:37:57 +01:00
|
|
|
},
|
|
|
|
output: {
|
2024-12-10 16:31:21 +01:00
|
|
|
filename: 'js/[name].min.js',
|
|
|
|
path: path.resolve(__dirname, 'tpl/vintage/')
|
2018-02-24 18:37:57 +01:00
|
|
|
},
|
|
|
|
module: {
|
|
|
|
rules: [
|
|
|
|
{
|
|
|
|
test: /\.js$/,
|
|
|
|
exclude: /node_modules/,
|
|
|
|
use: {
|
|
|
|
loader: 'babel-loader',
|
|
|
|
options: {
|
|
|
|
presets: [
|
2023-05-24 11:35:15 +02:00
|
|
|
'@babel/preset-env',
|
2018-02-24 18:37:57 +01:00
|
|
|
]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
test: /\.css$/,
|
2023-05-24 11:35:15 +02:00
|
|
|
use: [
|
|
|
|
{
|
|
|
|
loader: MiniCssExtractPlugin.loader,
|
|
|
|
},
|
|
|
|
'css-loader',
|
|
|
|
'sass-loader',
|
|
|
|
],
|
2018-02-24 18:37:57 +01:00
|
|
|
},
|
|
|
|
{
|
|
|
|
test: /\.(gif|png|jpe?g|svg|ico)$/i,
|
2024-12-10 16:31:21 +01:00
|
|
|
type: 'asset/resource',
|
|
|
|
generator: {
|
|
|
|
filename: 'img/[name][ext]'
|
|
|
|
}
|
2018-02-24 18:37:57 +01:00
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
2023-05-24 11:35:15 +02:00
|
|
|
optimization: {
|
|
|
|
minimize: true,
|
|
|
|
minimizer: [new TerserPlugin()],
|
|
|
|
},
|
2018-02-24 18:37:57 +01:00
|
|
|
plugins: [
|
2023-05-24 11:35:15 +02:00
|
|
|
extractCss,
|
2018-02-24 18:37:57 +01:00
|
|
|
],
|
|
|
|
},
|
|
|
|
];
|