Part-DB /
Part-DB-symfony
| 1 | /* |
||
| 2 | * This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony) |
||
| 3 | * |
||
| 4 | * Copyright (C) 2019 Jan Böhmer (https://github.com/jbtronics) |
||
| 5 | * |
||
| 6 | * This program is free software; you can redistribute it and/or |
||
| 7 | * modify it under the terms of the GNU General Public License |
||
| 8 | * as published by the Free Software Foundation; either version 2 |
||
| 9 | * of the License, or (at your option) any later version. |
||
| 10 | * |
||
| 11 | * This program is distributed in the hope that it will be useful, |
||
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
||
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||
| 14 | * GNU General Public License for more details. |
||
| 15 | * |
||
| 16 | * You should have received a copy of the GNU General Public License |
||
| 17 | * along with this program; if not, write to the Free Software |
||
| 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA |
||
| 19 | * |
||
| 20 | */ |
||
| 21 | |||
| 22 | var Encore = require('@symfony/webpack-encore'); |
||
| 23 | const CopyPlugin = require('copy-webpack-plugin'); |
||
| 24 | |||
| 25 | const zlib = require('zlib'); |
||
|
0 ignored issues
–
show
Unused Code
introduced
by
Loading history...
|
|||
| 26 | const CompressionPlugin = require("compression-webpack-plugin"); |
||
| 27 | const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin; |
||
| 28 | const CKEditorWebpackPlugin = require( '@ckeditor/ckeditor5-dev-webpack-plugin' ); |
||
| 29 | const { styles } = require( '@ckeditor/ckeditor5-dev-utils' ); |
||
| 30 | |||
| 31 | // Manually configure the runtime environment if not already configured yet by the "encore" command. |
||
| 32 | // It's useful when you use tools that rely on webpack.config.js file. |
||
| 33 | if (!Encore.isRuntimeEnvironmentConfigured()) { |
||
| 34 | Encore.configureRuntimeEnvironment(process.env.NODE_ENV || 'dev'); |
||
| 35 | } |
||
| 36 | |||
| 37 | Encore |
||
| 38 | // directory where compiled assets will be stored |
||
| 39 | .setOutputPath('public/build/') |
||
| 40 | // public path used by the web server to access the output path |
||
| 41 | .setPublicPath('/build') |
||
| 42 | // only needed for CDN's or subdirectory deploy |
||
| 43 | //.setManifestKeyPrefix('build/') |
||
| 44 | |||
| 45 | /** |
||
| 46 | * If you are putting Part-DB into a sub directory you have to uncomment these lines and |
||
| 47 | * replace "part-db/" with your path to Part-DB |
||
| 48 | */ |
||
| 49 | //.setPublicPath('/part-db/build') |
||
| 50 | //.setManifestKeyPrefix('build/') |
||
| 51 | |||
| 52 | /* |
||
| 53 | * ENTRY CONFIG |
||
| 54 | * |
||
| 55 | * Add 1 entry for each "page" of your app |
||
| 56 | * (including one that's included on every page - e.g. "app") |
||
| 57 | * |
||
| 58 | * Each entry will result in one JavaScript file (e.g. app.js) |
||
| 59 | * and one CSS file (e.g. app.css) if you JavaScript imports CSS. |
||
| 60 | */ |
||
| 61 | .addEntry('app', './assets/js/app.js') |
||
| 62 | .addEntry('webauthn_tfa', './assets/js/webauthn_tfa.js') |
||
| 63 | |||
| 64 | // enables the Symfony UX Stimulus bridge (used in assets/bootstrap.js) |
||
| 65 | .enableStimulusBridge('./assets/controllers.json') |
||
| 66 | //.addEntry('page1', './assets/js/page1.js') |
||
| 67 | //.addEntry('page2', './assets/js/page2.js') |
||
| 68 | |||
| 69 | // When enabled, Webpack "splits" your files into smaller pieces for greater optimization. |
||
| 70 | .splitEntryChunks() |
||
| 71 | |||
| 72 | // will require an extra script tag for runtime.js |
||
| 73 | // but, you probably want this, unless you're building a single-page app |
||
| 74 | .enableSingleRuntimeChunk() |
||
| 75 | |||
| 76 | /* |
||
| 77 | * FEATURE CONFIG |
||
| 78 | * |
||
| 79 | * Enable & configure other features below. For a full |
||
| 80 | * list of features, see: |
||
| 81 | * https://symfony.com/doc/current/frontend.html#adding-more-features |
||
| 82 | */ |
||
| 83 | .cleanupOutputBeforeBuild() |
||
| 84 | .enableBuildNotifications() |
||
| 85 | .enableSourceMaps(!Encore.isProduction()) |
||
| 86 | // enables hashed filenames (e.g. app.abc123.css) |
||
| 87 | //.enableVersioning(Encore.isProduction()) |
||
| 88 | .enableVersioning() |
||
| 89 | |||
| 90 | // configure Babel |
||
| 91 | // .configureBabel((config) => { |
||
| 92 | // config.plugins.push('@babel/a-babel-plugin'); |
||
| 93 | // }) |
||
| 94 | |||
| 95 | // enables and configure @babel/preset-env polyfills |
||
| 96 | .configureBabelPresetEnv((config) => { |
||
| 97 | config.useBuiltIns = 'usage'; |
||
| 98 | config.corejs = '3.23'; |
||
| 99 | }) |
||
| 100 | // enables Sass/SCSS support |
||
| 101 | //.enableSassLoader() |
||
| 102 | |||
| 103 | // uncomment if you use TypeScript |
||
| 104 | .enableTypeScriptLoader() |
||
| 105 | |||
| 106 | // uncomment if you use React |
||
| 107 | //.enableReactPreset() |
||
| 108 | |||
| 109 | // uncomment to get integrity="..." attributes on your script & link tags |
||
| 110 | // requires WebpackEncoreBundle 1.4 or higher |
||
| 111 | .enableIntegrityHashes(Encore.isProduction()) |
||
| 112 | .addPlugin(new CopyPlugin({ |
||
| 113 | patterns: [ |
||
| 114 | { |
||
| 115 | from: 'node_modules/bootswatch/dist/*/*.min.css', |
||
| 116 | to({ context, absoluteFilename }) { |
||
| 117 | const regexp = /.*([\/\\])(.+)([\/\\]).*\.css$/g; |
||
| 118 | const array = [...absoluteFilename.matchAll(regexp)]; |
||
| 119 | return 'themes/'+array[0][2]+'[ext]'; |
||
| 120 | } |
||
| 121 | }, |
||
| 122 | { |
||
| 123 | from: 'node_modules/bootstrap/dist/css/bootstrap.min.css', |
||
| 124 | to: 'themes/bootstrap.css' |
||
| 125 | } |
||
| 126 | ]})) |
||
| 127 | |||
| 128 | // uncomment if you're having problems with a jQuery plugin |
||
| 129 | .autoProvidejQuery() |
||
| 130 | |||
| 131 | .addPlugin( new CKEditorWebpackPlugin( { |
||
| 132 | // See https://ckeditor.com/docs/ckeditor5/latest/features/ui-language.html |
||
| 133 | language: 'en', |
||
| 134 | addMainLanguageTranslationsToAllAssets: true, |
||
| 135 | additionalLanguages: 'all', |
||
| 136 | outputDirectory: 'ckeditor_translations' |
||
| 137 | } ) ) |
||
| 138 | |||
| 139 | // Use raw-loader for CKEditor 5 SVG files. |
||
| 140 | .addRule( { |
||
| 141 | test: /ckeditor5-[^/\\]+[/\\]theme[/\\]icons[/\\][^/\\]+\.svg$/, |
||
| 142 | loader: 'raw-loader' |
||
| 143 | } ) |
||
| 144 | |||
| 145 | // Configure other image loaders to exclude CKEditor 5 SVG files. |
||
| 146 | .configureLoaderRule( 'images', loader => { |
||
| 147 | loader.exclude = /ckeditor5-[^/\\]+[/\\]theme[/\\]icons[/\\][^/\\]+\.svg$/; |
||
| 148 | } ) |
||
| 149 | |||
| 150 | // Configure PostCSS loader. |
||
| 151 | .addLoader({ |
||
| 152 | test: /ckeditor5-[^/\\]+[/\\]theme[/\\].+\.css$/, |
||
| 153 | loader: 'postcss-loader', |
||
| 154 | options: { |
||
| 155 | postcssOptions: styles.getPostCssConfig( { |
||
| 156 | themeImporter: { |
||
| 157 | themePath: require.resolve( '@ckeditor/ckeditor5-theme-lark' ) |
||
| 158 | }, |
||
| 159 | minify: true |
||
| 160 | } ) |
||
| 161 | } |
||
| 162 | } ) |
||
| 163 | |||
| 164 | ; |
||
| 165 | |||
| 166 | |||
| 167 | |||
| 168 | //Copy bootstrap map if in debug mode |
||
| 169 | if (Encore.isDev()) { |
||
| 170 | Encore.addPlugin(new CopyPlugin({ |
||
| 171 | patterns: [ |
||
| 172 | { |
||
| 173 | from: 'node_modules/bootstrap/dist/css/bootstrap.min.css.map', |
||
| 174 | to: 'themes/bootstrap.min.css.map' |
||
| 175 | } |
||
| 176 | ]})) |
||
| 177 | } |
||
| 178 | |||
| 179 | if (Encore.isProduction()) { |
||
| 180 | Encore.addPlugin(new CompressionPlugin({ |
||
| 181 | filename: '[path][base].br', |
||
| 182 | algorithm: 'brotliCompress', |
||
| 183 | test: /\.(js|css|html|svg)$/, |
||
| 184 | compressionOptions: { |
||
| 185 | // zlib’s `level` option matches Brotli’s `BROTLI_PARAM_QUALITY` option. |
||
| 186 | level: 11, |
||
| 187 | }, |
||
| 188 | //threshold: 10240, |
||
| 189 | minRatio: 0.8, |
||
| 190 | deleteOriginalAssets: false, |
||
| 191 | })) |
||
| 192 | |||
| 193 | .addPlugin(new CompressionPlugin({ |
||
| 194 | filename: '[path][base].gz', |
||
| 195 | algorithm: 'gzip', |
||
| 196 | test: /\.(js|css|html|svg)$/, |
||
| 197 | deleteOriginalAssets: false, |
||
| 198 | })) |
||
| 199 | } |
||
| 200 | |||
| 201 | if (Encore.isDev()) { |
||
| 202 | //Only uncomment if needed, as this cause problems with Github actions (job does not finish) |
||
| 203 | Encore.addPlugin(new BundleAnalyzerPlugin()); |
||
| 204 | } |
||
| 205 | |||
| 206 | |||
| 207 | module.exports = Encore.getWebpackConfig(); |
||
| 208 |