aboutsummaryrefslogtreecommitdiffhomepage
path: root/webpack.config.js
diff options
context:
space:
mode:
authorArthurHoaro <arthur@hoa.ro>2020-10-13 12:05:08 +0200
committerArthurHoaro <arthur@hoa.ro>2020-10-13 12:05:08 +0200
commitb6f678a5a1d15acf284ebcec16c905e976671ce1 (patch)
tree33c7da831482ed79c44896ef19c73c72ada84f2e /webpack.config.js
parentb14687036b9b800681197f51fdc47e62f0c88e2e (diff)
parent1c1520b6b98ab20201bfe15577782a52320339df (diff)
downloadShaarli-b6f678a5a1d15acf284ebcec16c905e976671ce1.tar.gz
Shaarli-b6f678a5a1d15acf284ebcec16c905e976671ce1.tar.zst
Shaarli-b6f678a5a1d15acf284ebcec16c905e976671ce1.zip
Merge branch 'v0.12' into latest
Diffstat (limited to 'webpack.config.js')
-rw-r--r--webpack.config.js72
1 files changed, 39 insertions, 33 deletions
diff --git a/webpack.config.js b/webpack.config.js
index ed548c73..a73758cc 100644
--- a/webpack.config.js
+++ b/webpack.config.js
@@ -2,26 +2,21 @@ const path = require('path');
2const glob = require('glob'); 2const glob = require('glob');
3 3
4// Minify JS 4// Minify JS
5const MinifyPlugin = require('babel-minify-webpack-plugin'); 5const TerserPlugin = require('terser-webpack-plugin');
6 6
7// This plugin extracts the CSS into its own file instead of tying it with the JS. 7// This plugin extracts the CSS into its own file instead of tying it with the JS.
8// It prevents: 8// It prevents:
9// - not having styles due to a JS error 9// - not having styles due to a JS error
10// - the flash page without styles during JS loading 10// - the flash page without styles during JS loading
11const ExtractTextPlugin = require("extract-text-webpack-plugin"); 11const MiniCssExtractPlugin = require("mini-css-extract-plugin");
12 12
13const extractCssDefault = new ExtractTextPlugin({ 13const extractCss = new MiniCssExtractPlugin({
14 filename: "../css/[name].min.css", 14 filename: "../css/[name].min.css",
15 publicPath: 'tpl/default/css/',
16});
17
18const extractCssVintage = new ExtractTextPlugin({
19 filename: "../css/[name].min.css",
20 publicPath: 'tpl/vintage/css/',
21}); 15});
22 16
23module.exports = [ 17module.exports = [
24 { 18 {
19 mode: 'production',
25 entry: { 20 entry: {
26 thumbnails: './assets/common/js/thumbnails.js', 21 thumbnails: './assets/common/js/thumbnails.js',
27 thumbnails_update: './assets/common/js/thumbnails-update.js', 22 thumbnails_update: './assets/common/js/thumbnails-update.js',
@@ -30,6 +25,7 @@ module.exports = [
30 './assets/default/js/base.js', 25 './assets/default/js/base.js',
31 './assets/default/scss/shaarli.scss', 26 './assets/default/scss/shaarli.scss',
32 ].concat(glob.sync('./assets/default/img/*')), 27 ].concat(glob.sync('./assets/default/img/*')),
28 markdown: './assets/common/css/markdown.css',
33 }, 29 },
34 output: { 30 output: {
35 filename: '[name].min.js', 31 filename: '[name].min.js',
@@ -44,23 +40,23 @@ module.exports = [
44 loader: 'babel-loader', 40 loader: 'babel-loader',
45 options: { 41 options: {
46 presets: [ 42 presets: [
47 'babel-preset-env', 43 '@babel/preset-env',
48 ] 44 ]
49 } 45 }
50 } 46 }
51 }, 47 },
52 { 48 {
53 test: /\.scss/, 49 test: /\.s?css/,
54 use: extractCssDefault.extract({ 50 use: [
55 use: [{ 51 {
56 loader: "css-loader", 52 loader: MiniCssExtractPlugin.loader,
57 options: { 53 options: {
58 minimize: true, 54 publicPath: 'tpl/default/css/',
59 } 55 },
60 }, { 56 },
61 loader: "sass-loader" 57 'css-loader',
62 }], 58 'sass-loader',
63 }) 59 ],
64 }, 60 },
65 { 61 {
66 test: /\.(gif|png|jpe?g|svg|ico)$/i, 62 test: /\.(gif|png|jpe?g|svg|ico)$/i,
@@ -80,23 +76,28 @@ module.exports = [
80 options: { 76 options: {
81 name: '../fonts/[name].[ext]', 77 name: '../fonts/[name].[ext]',
82 // do not add a publicPath here because it's already handled by CSS's publicPath 78 // do not add a publicPath here because it's already handled by CSS's publicPath
83 publicPath: '', 79 publicPath: '../default/',
84 } 80 }
85 }, 81 },
86 ], 82 ],
87 }, 83 },
84 optimization: {
85 minimize: true,
86 minimizer: [new TerserPlugin()],
87 },
88 plugins: [ 88 plugins: [
89 new MinifyPlugin(), 89 extractCss,
90 extractCssDefault,
91 ], 90 ],
92 }, 91 },
93 { 92 {
93 mode: 'production',
94 entry: { 94 entry: {
95 shaarli: [ 95 shaarli: [
96 './assets/vintage/js/base.js', 96 './assets/vintage/js/base.js',
97 './assets/vintage/css/reset.css', 97 './assets/vintage/css/reset.css',
98 './assets/vintage/css/shaarli.css', 98 './assets/vintage/css/shaarli.css',
99 ].concat(glob.sync('./assets/vintage/img/*')), 99 ].concat(glob.sync('./assets/vintage/img/*')),
100 markdown: './assets/common/css/markdown.css',
100 thumbnails: './assets/common/js/thumbnails.js', 101 thumbnails: './assets/common/js/thumbnails.js',
101 thumbnails_update: './assets/common/js/thumbnails-update.js', 102 thumbnails_update: './assets/common/js/thumbnails-update.js',
102 }, 103 },
@@ -113,21 +114,23 @@ module.exports = [
113 loader: 'babel-loader', 114 loader: 'babel-loader',
114 options: { 115 options: {
115 presets: [ 116 presets: [
116 'babel-preset-env', 117 '@babel/preset-env',
117 ] 118 ]
118 } 119 }
119 } 120 }
120 }, 121 },
121 { 122 {
122 test: /\.css$/, 123 test: /\.css$/,
123 use: extractCssVintage.extract({ 124 use: [
124 use: [{ 125 {
125 loader: "css-loader", 126 loader: MiniCssExtractPlugin.loader,
126 options: { 127 options: {
127 minimize: true, 128 publicPath: 'tpl/vintage/css/',
128 } 129 },
129 }], 130 },
130 }) 131 'css-loader',
132 'sass-loader',
133 ],
131 }, 134 },
132 { 135 {
133 test: /\.(gif|png|jpe?g|svg|ico)$/i, 136 test: /\.(gif|png|jpe?g|svg|ico)$/i,
@@ -143,9 +146,12 @@ module.exports = [
143 }, 146 },
144 ], 147 ],
145 }, 148 },
149 optimization: {
150 minimize: true,
151 minimizer: [new TerserPlugin()],
152 },
146 plugins: [ 153 plugins: [
147 new MinifyPlugin(), 154 extractCss,
148 extractCssVintage,
149 ], 155 ],
150 }, 156 },
151]; 157];