2020-06-23 13:44:14 +02:00
|
|
|
/*
|
|
|
|
|
2021-01-01 22:37:25 +01:00
|
|
|
Copyright (c) 2018 - 2021 Michael Mayer <hello@photoprism.org>
|
2020-06-23 13:44:14 +02:00
|
|
|
|
|
|
|
This program is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU Affero General Public License as published
|
|
|
|
by the Free Software Foundation, either version 3 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU Affero General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU Affero General Public License
|
|
|
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
|
2020-09-21 02:48:22 +02:00
|
|
|
PhotoPrism® is a registered trademark of Michael Mayer. You may use it as required
|
2020-06-23 13:53:11 +02:00
|
|
|
to describe our software, run your own server, for educational purposes, but not for
|
|
|
|
offering commercial goods, products, or services without prior written permission.
|
|
|
|
In other words, please ask.
|
2020-06-23 13:44:14 +02:00
|
|
|
|
|
|
|
Feel free to send an e-mail to hello@photoprism.org if you have questions,
|
|
|
|
want to support our work, or just want to say hello.
|
|
|
|
|
|
|
|
Additional information can be found in our Developer Guide:
|
|
|
|
https://docs.photoprism.org/developer-guide/
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
2019-05-09 06:48:10 +02:00
|
|
|
const path = require("path");
|
|
|
|
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
|
2021-07-26 00:05:50 +02:00
|
|
|
const ESLintPlugin = require("eslint-webpack-plugin");
|
2021-07-12 19:25:37 +02:00
|
|
|
const OfflinePlugin = require("@lcdp/offline-plugin");
|
2019-05-09 06:48:10 +02:00
|
|
|
const webpack = require("webpack");
|
|
|
|
const isDev = process.env.NODE_ENV !== "production";
|
2021-07-12 19:25:37 +02:00
|
|
|
const { VueLoaderPlugin } = require("vue-loader");
|
2018-07-27 17:31:39 +02:00
|
|
|
|
2020-12-18 14:42:36 +01:00
|
|
|
if (isDev) {
|
|
|
|
console.log("Building frontend in DEVELOPMENT mode. Please wait.");
|
2019-05-20 23:21:52 +02:00
|
|
|
} else {
|
2020-12-18 14:42:36 +01:00
|
|
|
console.log("Building frontend in PRODUCTION mode. Please wait.");
|
2019-05-20 23:21:52 +02:00
|
|
|
}
|
|
|
|
|
2019-05-28 01:18:27 +02:00
|
|
|
const PATHS = {
|
2020-12-18 14:42:36 +01:00
|
|
|
app: path.join(__dirname, "src/app.js"),
|
|
|
|
share: path.join(__dirname, "src/share.js"),
|
|
|
|
js: path.join(__dirname, "src"),
|
|
|
|
css: path.join(__dirname, "src/css"),
|
|
|
|
build: path.join(__dirname, "../assets/static/build"),
|
2019-05-28 01:18:27 +02:00
|
|
|
};
|
|
|
|
|
2018-07-27 17:31:39 +02:00
|
|
|
const config = {
|
2020-12-18 14:42:36 +01:00
|
|
|
mode: isDev ? "development" : "production",
|
|
|
|
devtool: isDev ? "inline-source-map" : false,
|
2021-07-12 19:25:37 +02:00
|
|
|
optimization: {
|
|
|
|
minimize: !isDev,
|
|
|
|
},
|
2020-12-18 14:42:36 +01:00
|
|
|
entry: {
|
|
|
|
app: PATHS.app,
|
|
|
|
share: PATHS.share,
|
|
|
|
},
|
|
|
|
output: {
|
|
|
|
path: PATHS.build,
|
|
|
|
filename: "[name].js",
|
|
|
|
},
|
|
|
|
resolve: {
|
|
|
|
modules: [path.join(__dirname, "src"), path.join(__dirname, "node_modules")],
|
|
|
|
alias: {
|
|
|
|
vue: isDev ? "vue/dist/vue.js" : "vue/dist/vue.min.js",
|
2018-07-27 17:31:39 +02:00
|
|
|
},
|
2020-12-18 14:42:36 +01:00
|
|
|
},
|
|
|
|
plugins: [
|
|
|
|
new MiniCssExtractPlugin({
|
|
|
|
filename: "[name].css",
|
2021-07-12 19:25:37 +02:00
|
|
|
experimentalUseImportModule: false,
|
2020-12-18 14:42:36 +01:00
|
|
|
}),
|
2021-07-12 19:25:37 +02:00
|
|
|
new webpack.ProgressPlugin(),
|
|
|
|
new VueLoaderPlugin(),
|
2021-07-13 22:54:03 +02:00
|
|
|
new OfflinePlugin({
|
|
|
|
relativePaths: false,
|
|
|
|
publicPath: "/",
|
2021-07-13 23:07:02 +02:00
|
|
|
excludes: ["**/*.txt", "**/*.css", "**/*.js", "**/*.*"],
|
2021-07-13 22:54:03 +02:00
|
|
|
rewrites: function (asset) {
|
|
|
|
return "/static/build/" + asset;
|
|
|
|
},
|
|
|
|
}),
|
2020-12-18 14:42:36 +01:00
|
|
|
],
|
|
|
|
performance: {
|
|
|
|
hints: isDev ? false : "error",
|
|
|
|
maxEntrypointSize: 4000000,
|
|
|
|
maxAssetSize: 4000000,
|
|
|
|
},
|
|
|
|
module: {
|
|
|
|
rules: [
|
|
|
|
{
|
|
|
|
test: /\.vue$/,
|
|
|
|
include: PATHS.js,
|
2021-07-12 19:25:37 +02:00
|
|
|
use: [
|
|
|
|
{
|
|
|
|
loader: "vue-loader",
|
|
|
|
options: {
|
|
|
|
loaders: {
|
|
|
|
js: "babel-loader",
|
|
|
|
css: "css-loader",
|
|
|
|
},
|
|
|
|
},
|
2020-12-18 14:42:36 +01:00
|
|
|
},
|
2021-07-12 19:25:37 +02:00
|
|
|
],
|
2020-12-18 14:42:36 +01:00
|
|
|
},
|
|
|
|
{
|
|
|
|
test: /\.js$/,
|
|
|
|
include: PATHS.js,
|
|
|
|
exclude: (file) => /node_modules/.test(file),
|
2021-07-12 19:25:37 +02:00
|
|
|
use: [
|
|
|
|
{
|
|
|
|
loader: "babel-loader",
|
|
|
|
options: {
|
|
|
|
sourceMap: isDev,
|
|
|
|
compact: false,
|
|
|
|
presets: ["@babel/preset-env"],
|
|
|
|
plugins: [
|
|
|
|
"@babel/plugin-proposal-object-rest-spread",
|
|
|
|
"@babel/plugin-proposal-class-properties",
|
|
|
|
],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
],
|
2020-12-18 14:42:36 +01:00
|
|
|
},
|
|
|
|
{
|
|
|
|
test: /\.css$/,
|
|
|
|
include: PATHS.css,
|
|
|
|
exclude: /node_modules/,
|
|
|
|
use: [
|
|
|
|
{
|
|
|
|
loader: MiniCssExtractPlugin.loader,
|
|
|
|
options: {
|
|
|
|
publicPath: PATHS.build,
|
2018-07-27 17:31:39 +02:00
|
|
|
},
|
2020-12-18 14:42:36 +01:00
|
|
|
},
|
2021-07-12 19:25:37 +02:00
|
|
|
{
|
|
|
|
loader: "css-loader",
|
|
|
|
options: {
|
|
|
|
sourceMap: true,
|
|
|
|
importLoaders: 1,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
"resolve-url-loader",
|
|
|
|
{
|
|
|
|
loader: "postcss-loader",
|
|
|
|
options: {
|
|
|
|
sourceMap: true,
|
|
|
|
postcssOptions: {
|
|
|
|
config: path.resolve(__dirname, "./postcss.config.js"),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2020-12-18 14:42:36 +01:00
|
|
|
],
|
|
|
|
},
|
|
|
|
{
|
|
|
|
test: /\.css$/,
|
|
|
|
include: /node_modules/,
|
2021-07-12 19:25:37 +02:00
|
|
|
use: [
|
|
|
|
{
|
|
|
|
loader: MiniCssExtractPlugin.loader,
|
|
|
|
options: {
|
|
|
|
publicPath: PATHS.build,
|
|
|
|
},
|
|
|
|
},
|
2020-12-18 14:42:36 +01:00
|
|
|
{
|
|
|
|
loader: "css-loader",
|
2021-07-12 19:25:37 +02:00
|
|
|
options: {
|
|
|
|
sourceMap: true,
|
|
|
|
importLoaders: 1,
|
|
|
|
},
|
2020-12-18 14:42:36 +01:00
|
|
|
},
|
2021-07-12 19:25:37 +02:00
|
|
|
"resolve-url-loader",
|
2020-12-18 14:42:36 +01:00
|
|
|
{
|
|
|
|
loader: "postcss-loader",
|
|
|
|
options: {
|
2021-07-12 19:25:37 +02:00
|
|
|
sourceMap: true,
|
|
|
|
postcssOptions: {
|
|
|
|
config: path.resolve(__dirname, "./postcss.config.js"),
|
2020-12-18 14:42:36 +01:00
|
|
|
},
|
2018-07-27 17:31:39 +02:00
|
|
|
},
|
2020-12-18 14:42:36 +01:00
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
{
|
|
|
|
test: /\.s[c|a]ss$/,
|
|
|
|
use: [
|
2021-07-12 19:25:37 +02:00
|
|
|
{
|
|
|
|
loader: MiniCssExtractPlugin.loader,
|
|
|
|
options: {
|
|
|
|
publicPath: PATHS.build,
|
|
|
|
},
|
|
|
|
},
|
2020-12-18 14:42:36 +01:00
|
|
|
{
|
|
|
|
loader: "css-loader",
|
2021-07-12 19:25:37 +02:00
|
|
|
options: {
|
|
|
|
sourceMap: true,
|
|
|
|
importLoaders: 1,
|
|
|
|
},
|
2020-12-18 14:42:36 +01:00
|
|
|
},
|
2021-07-12 19:25:37 +02:00
|
|
|
"resolve-url-loader",
|
2020-12-18 14:42:36 +01:00
|
|
|
{
|
|
|
|
loader: "postcss-loader",
|
|
|
|
options: {
|
2021-07-12 19:25:37 +02:00
|
|
|
sourceMap: true,
|
|
|
|
postcssOptions: {
|
|
|
|
config: path.resolve(__dirname, "./postcss.config.js"),
|
2020-12-18 14:42:36 +01:00
|
|
|
},
|
2018-07-27 17:31:39 +02:00
|
|
|
},
|
2020-12-18 14:42:36 +01:00
|
|
|
},
|
|
|
|
"sass-loader",
|
2018-07-27 17:31:39 +02:00
|
|
|
],
|
2020-12-18 14:42:36 +01:00
|
|
|
},
|
|
|
|
{
|
|
|
|
test: /\.(png|jpg|jpeg|gif)$/,
|
|
|
|
loader: "file-loader",
|
|
|
|
options: {
|
|
|
|
name: "[hash].[ext]",
|
2021-07-12 19:25:37 +02:00
|
|
|
publicPath: "./img",
|
2020-12-18 14:42:36 +01:00
|
|
|
outputPath: "img",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
test: /\.(woff(2)?|ttf|eot)(\?v=\d+\.\d+\.\d+)?$/,
|
|
|
|
loader: "file-loader",
|
|
|
|
options: {
|
|
|
|
name: "[hash].[ext]",
|
2021-07-05 16:41:43 +02:00
|
|
|
publicPath: "./fonts",
|
2020-12-18 14:42:36 +01:00
|
|
|
outputPath: "fonts",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
test: /\.svg/,
|
|
|
|
use: {
|
|
|
|
loader: "svg-url-loader",
|
|
|
|
options: {},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
2018-07-27 17:31:39 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
// No sourcemap for production
|
2019-05-07 15:41:33 +02:00
|
|
|
if (isDev) {
|
2020-12-18 14:42:36 +01:00
|
|
|
const devToolPlugin = new webpack.SourceMapDevToolPlugin({
|
|
|
|
filename: "[file].map",
|
|
|
|
});
|
2018-09-13 20:54:34 +02:00
|
|
|
|
2020-12-18 14:42:36 +01:00
|
|
|
config.plugins.push(devToolPlugin);
|
2021-07-26 00:05:50 +02:00
|
|
|
|
|
|
|
const esLintPlugin = new ESLintPlugin({
|
|
|
|
formatter: require("eslint-formatter-pretty"),
|
|
|
|
extensions: ["js"],
|
|
|
|
});
|
|
|
|
|
|
|
|
config.plugins.push(esLintPlugin);
|
2018-07-27 17:31:39 +02:00
|
|
|
}
|
|
|
|
|
2019-05-07 15:41:33 +02:00
|
|
|
module.exports = config;
|