2020-01-09 15:12:17 +00:00
|
|
|
const baseUrl = process.env.BASE_URL || '/front/'
|
2018-08-11 14:21:14 +00:00
|
|
|
|
2018-12-19 20:45:12 +00:00
|
|
|
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
|
2018-12-19 21:22:51 +00:00
|
|
|
const webpack = require('webpack');
|
2019-09-14 13:08:49 +00:00
|
|
|
const PurgecssPlugin = require('purgecss-webpack-plugin')
|
2019-12-26 10:38:26 +00:00
|
|
|
const PreloadWebpackPlugin = require('preload-webpack-plugin');
|
2019-09-14 13:08:49 +00:00
|
|
|
const glob = require('glob-all')
|
|
|
|
const path = require('path')
|
2018-12-19 21:22:51 +00:00
|
|
|
let plugins = [
|
|
|
|
// do not include moment.js locales since it's quite heavy
|
|
|
|
new webpack.IgnorePlugin(/^\.\/locale$/, /moment$/),
|
2019-12-26 10:38:26 +00:00
|
|
|
new PreloadWebpackPlugin({
|
|
|
|
rel: 'preload',
|
|
|
|
include: ['audio', 'core', 'about']
|
|
|
|
}),
|
2018-12-19 21:22:51 +00:00
|
|
|
]
|
2018-12-19 20:45:12 +00:00
|
|
|
if (process.env.BUNDLE_ANALYZE === '1') {
|
|
|
|
plugins.push(new BundleAnalyzerPlugin())
|
|
|
|
}
|
2020-03-03 10:42:52 +00:00
|
|
|
// Disabled because it causes some issues, like #1032, since some useful rules are still
|
|
|
|
// removed, and we cannot detect this during development
|
|
|
|
// plugins.push(
|
|
|
|
// new PurgecssPlugin({
|
|
|
|
// paths: glob.sync([
|
|
|
|
// path.join(__dirname, './public/index.html'),
|
|
|
|
// path.join(__dirname, './public/embed.html'),
|
|
|
|
// path.join(__dirname, './**/*.vue'),
|
|
|
|
// path.join(__dirname, './src/**/*.js')
|
|
|
|
// ]),
|
|
|
|
// whitelist: ['scale'],
|
|
|
|
// whitelistPatterns: [/plyr/, /toast/, /transition/, /visible/],
|
|
|
|
// whitelistPatternsChildren: [/plyr/, /dropdown/, /upward/]
|
|
|
|
// }),
|
|
|
|
// )
|
2018-08-11 14:21:14 +00:00
|
|
|
module.exports = {
|
2020-02-25 13:49:50 +00:00
|
|
|
publicPath: baseUrl,
|
2019-07-10 13:08:48 +00:00
|
|
|
productionSourceMap: false,
|
2020-01-08 11:16:41 +00:00
|
|
|
// Add settings for manifest file
|
|
|
|
pwa: {
|
|
|
|
name: 'Funkwhale',
|
|
|
|
themeColor: '#f2711c',
|
|
|
|
msTileColor: '#000000',
|
|
|
|
appleMobileWebAppCapable: 'yes',
|
|
|
|
appleMobileWebAppStatusBarStyle: 'black',
|
|
|
|
workboxPluginMode: 'InjectManifest',
|
|
|
|
manifestOptions: {
|
2020-01-09 15:20:29 +00:00
|
|
|
display: 'minimal-ui',
|
2020-01-08 11:16:41 +00:00
|
|
|
start_url: '.',
|
|
|
|
description: 'A social platform to enjoy and share music',
|
|
|
|
scope: "/",
|
|
|
|
categories: ["music"],
|
|
|
|
icons: [
|
|
|
|
{
|
2020-01-09 15:12:17 +00:00
|
|
|
'src': baseUrl + 'favicon.png',
|
2020-01-08 11:16:41 +00:00
|
|
|
'sizes': '192x192',
|
|
|
|
'type': 'image/png'
|
|
|
|
}, {
|
2020-01-09 15:12:17 +00:00
|
|
|
'src': baseUrl + 'favicon.png',
|
2020-01-08 11:16:41 +00:00
|
|
|
'sizes': '512x512',
|
|
|
|
'type': 'image/png'
|
|
|
|
},
|
|
|
|
]
|
|
|
|
},
|
|
|
|
workboxOptions: {
|
|
|
|
importWorkboxFrom: 'local',
|
|
|
|
// swSrc is required in InjectManifest mode.
|
|
|
|
swSrc: 'src/service-worker.js',
|
|
|
|
swDest: 'service-worker.js',
|
2020-01-09 12:22:16 +00:00
|
|
|
exclude: [
|
|
|
|
new RegExp('js/locale.*'),
|
|
|
|
new RegExp('js/moment-locale.*'),
|
|
|
|
new RegExp('js/admin.*'),
|
|
|
|
new RegExp('css/admin.*'),
|
|
|
|
]
|
2020-01-08 11:16:41 +00:00
|
|
|
},
|
|
|
|
iconPaths: {
|
|
|
|
favicon32: 'favicon.png',
|
|
|
|
favicon16: 'favicon.png',
|
|
|
|
appleTouchIcon: 'favicon.png',
|
|
|
|
maskIcon: 'favicon.png',
|
|
|
|
msTileImage: 'favicon.png'
|
|
|
|
}
|
|
|
|
},
|
2018-12-19 13:03:21 +00:00
|
|
|
pages: {
|
|
|
|
embed: {
|
|
|
|
entry: 'src/embed.js',
|
|
|
|
template: 'public/embed.html',
|
|
|
|
filename: 'embed.html',
|
2020-01-09 10:55:00 +00:00
|
|
|
chunks: ['chunk-vendors', 'chunk-common', 'chunk-embed-vendors', 'embed']
|
2018-12-19 13:03:21 +00:00
|
|
|
},
|
|
|
|
index: {
|
|
|
|
entry: 'src/main.js',
|
|
|
|
template: 'public/index.html',
|
2020-01-09 10:55:00 +00:00
|
|
|
filename: 'index.html',
|
|
|
|
chunks: ['chunk-vendors', 'chunk-common', 'chunk-index-vendors', 'index']
|
2018-12-19 13:03:21 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
chainWebpack: config => {
|
2020-02-25 14:42:44 +00:00
|
|
|
// config.plugins.delete('prefetch-embed')
|
|
|
|
// config.plugins.delete('preload-embed')
|
|
|
|
// config.plugins.delete('prefetch-index')
|
|
|
|
// TODO: Remove this workaround once https://github.com/vuejs/vue-cli/issues/2463 is fixed
|
|
|
|
// Remove preload plugins for multi-page build to prevent infinite recursion
|
|
|
|
['embed', 'index'].forEach(page => {
|
|
|
|
config.plugins.delete(`preload-${page}`)
|
|
|
|
config.plugins.delete(`prefetch-${page}`)
|
|
|
|
})
|
2020-01-09 10:55:00 +00:00
|
|
|
// needed to avoid having big dependedncies included in our lightweight
|
|
|
|
// embed.html, cf https://github.com/vuejs/vue-cli/issues/2381
|
|
|
|
const options = module.exports
|
|
|
|
const pages = options.pages
|
|
|
|
const pageKeys = Object.keys(pages)
|
|
|
|
|
|
|
|
// Long-term caching
|
|
|
|
|
|
|
|
const IS_VENDOR = /[\\/]node_modules[\\/]/
|
|
|
|
|
|
|
|
config.optimization
|
|
|
|
.splitChunks({
|
|
|
|
cacheGroups: {
|
|
|
|
vendors: {
|
|
|
|
name: 'chunk-vendors',
|
|
|
|
priority: -10,
|
|
|
|
chunks: 'initial',
|
|
|
|
minChunks: 2,
|
|
|
|
test: IS_VENDOR,
|
|
|
|
enforce: true,
|
|
|
|
},
|
|
|
|
...pageKeys.map(key => ({
|
|
|
|
name: `chunk-${key}-vendors`,
|
|
|
|
priority: -11,
|
|
|
|
chunks: chunk => chunk.name === key,
|
|
|
|
test: IS_VENDOR,
|
|
|
|
enforce: true,
|
|
|
|
})),
|
|
|
|
common: {
|
|
|
|
name: 'chunk-common',
|
|
|
|
priority: -20,
|
|
|
|
chunks: 'initial',
|
|
|
|
minChunks: 2,
|
|
|
|
reuseExistingChunk: true,
|
|
|
|
enforce: true,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
})
|
2018-12-19 13:03:21 +00:00
|
|
|
},
|
2018-08-11 14:21:14 +00:00
|
|
|
configureWebpack: {
|
2018-12-19 20:45:12 +00:00
|
|
|
plugins: plugins,
|
2019-07-10 13:08:48 +00:00
|
|
|
devtool: false
|
2018-08-11 14:21:14 +00:00
|
|
|
},
|
|
|
|
devServer: {
|
|
|
|
disableHostCheck: true,
|
2018-12-19 13:03:21 +00:00
|
|
|
// use https://node1.funkwhale.test/front-server/ if you use docker with federation
|
|
|
|
public: process.env.FRONT_DEVSERVER_URL || ('http://localhost:' + (process.env.VUE_PORT || '8080'))
|
2020-05-15 12:12:36 +00:00
|
|
|
},
|
|
|
|
css: {
|
|
|
|
loaderOptions: {
|
|
|
|
sass: {
|
|
|
|
implementation: require('sass')
|
|
|
|
}
|
|
|
|
}
|
2018-08-11 14:21:14 +00:00
|
|
|
}
|
|
|
|
}
|