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 | |||
| 28 | // Manually configure the runtime environment if not already configured yet by the "encore" command. |
||
| 29 | // It's useful when you use tools that rely on webpack.config.js file. |
||
| 30 | if (!Encore.isRuntimeEnvironmentConfigured()) { |
||
| 31 | Encore.configureRuntimeEnvironment(process.env.NODE_ENV || 'dev'); |
||
| 32 | } |
||
| 33 | |||
| 34 | Encore |
||
| 35 | // directory where compiled assets will be stored |
||
| 36 | .setOutputPath('public/build/') |
||
| 37 | // public path used by the web server to access the output path |
||
| 38 | .setPublicPath('/build') |
||
| 39 | // only needed for CDN's or sub-directory deploy |
||
| 40 | //.setManifestKeyPrefix('build/') |
||
| 41 | |||
| 42 | /** |
||
| 43 | * If you are putting Part-DB into a sub directory you have to uncomment these lines and |
||
| 44 | * replace "part-db/" with your path to Part-DB |
||
| 45 | */ |
||
| 46 | //.setPublicPath('/part-db/build') |
||
| 47 | //.setManifestKeyPrefix('build/') |
||
| 48 | |||
| 49 | /* |
||
| 50 | * ENTRY CONFIG |
||
| 51 | * |
||
| 52 | * Add 1 entry for each "page" of your app |
||
| 53 | * (including one that's included on every page - e.g. "app") |
||
| 54 | * |
||
| 55 | * Each entry will result in one JavaScript file (e.g. app.js) |
||
| 56 | * and one CSS file (e.g. app.css) if you JavaScript imports CSS. |
||
| 57 | */ |
||
| 58 | .addEntry('app', './assets/js/app.js') |
||
| 59 | |||
| 60 | .addEntry('ru2ftwofactor', './assets/js/u2f_auth.js') |
||
| 61 | //.addEntry('ajaxUI', './assets/ts_src/ajax_ui.ts') |
||
| 62 | //.addEntry('page1', './assets/js/page1.js') |
||
| 63 | //.addEntry('page2', './assets/js/page2.js') |
||
| 64 | |||
| 65 | // When enabled, Webpack "splits" your files into smaller pieces for greater optimization. |
||
| 66 | .splitEntryChunks() |
||
| 67 | |||
| 68 | // will require an extra script tag for runtime.js |
||
| 69 | // but, you probably want this, unless you're building a single-page app |
||
| 70 | .enableSingleRuntimeChunk() |
||
| 71 | |||
| 72 | /* |
||
| 73 | * FEATURE CONFIG |
||
| 74 | * |
||
| 75 | * Enable & configure other features below. For a full |
||
| 76 | * list of features, see: |
||
| 77 | * https://symfony.com/doc/current/frontend.html#adding-more-features |
||
| 78 | */ |
||
| 79 | .cleanupOutputBeforeBuild() |
||
| 80 | .enableBuildNotifications() |
||
| 81 | .enableSourceMaps(!Encore.isProduction()) |
||
| 82 | // enables hashed filenames (e.g. app.abc123.css) |
||
| 83 | .enableVersioning(Encore.isProduction()) |
||
| 84 | |||
| 85 | // enables @babel/preset-env polyfills |
||
| 86 | .configureBabelPresetEnv((config) => { |
||
| 87 | config.useBuiltIns = 'usage'; |
||
| 88 | config.corejs = 3; |
||
| 89 | }) |
||
| 90 | // enables Sass/SCSS support |
||
| 91 | //.enableSassLoader() |
||
| 92 | |||
| 93 | // uncomment if you use TypeScript |
||
| 94 | .enableTypeScriptLoader() |
||
| 95 | |||
| 96 | // uncomment if you're having problems with a jQuery plugin |
||
| 97 | .autoProvidejQuery() |
||
| 98 | |||
| 99 | .addPlugin(new CopyPlugin([ |
||
| 100 | { |
||
| 101 | from: 'node_modules/bootswatch/dist/*/*.min.css', |
||
| 102 | to: 'themes/[2].[ext]', |
||
| 103 | test: /.*([\/\\])(.+)([\/\\]).*\.css$/ |
||
| 104 | }, |
||
| 105 | { |
||
| 106 | from: 'node_modules/bootstrap/dist/css/bootstrap.min.css', |
||
| 107 | to: 'themes/bootstrap.css' |
||
| 108 | } |
||
| 109 | ])) |
||
| 110 | |||
| 111 | // uncomment if you use API Platform Admin (composer req api-admin) |
||
| 112 | //.enableReactPreset() |
||
| 113 | //.addEntry('admin', './assets/js/admin.js') |
||
| 114 | ; |
||
| 115 | |||
| 116 | if (Encore.isProduction()) { |
||
| 117 | Encore.addPlugin(new CompressionPlugin({ |
||
| 118 | filename: '[path].br[query]', |
||
| 119 | algorithm: 'brotliCompress', |
||
| 120 | test: /\.(js|css|html|svg)$/, |
||
| 121 | compressionOptions: { |
||
| 122 | // zlib’s `level` option matches Brotli’s `BROTLI_PARAM_QUALITY` option. |
||
| 123 | level: 11, |
||
| 124 | }, |
||
| 125 | //threshold: 10240, |
||
| 126 | minRatio: 0.8, |
||
| 127 | deleteOriginalAssets: false, |
||
| 128 | })) |
||
| 129 | |||
| 130 | .addPlugin(new CompressionPlugin({ |
||
| 131 | filename: '[path].gz[query]', |
||
| 132 | algorithm: 'gzip', |
||
| 133 | test: /\.(js|css|html|svg)$/, |
||
| 134 | deleteOriginalAssets: false, |
||
| 135 | })) |
||
| 136 | } |
||
| 137 | |||
| 138 | module.exports = Encore.getWebpackConfig(); |
||
| 139 |