2020-05-15 14:16:13 +00:00
|
|
|
/* eslint-env node */
|
|
|
|
|
2021-01-18 14:02:24 +00:00
|
|
|
const {
|
|
|
|
HTMLPlugins,
|
|
|
|
styleLoader,
|
|
|
|
commonLoaders,
|
|
|
|
default: common,
|
|
|
|
} = require('./webpack.common')
|
2019-07-08 09:13:51 +00:00
|
|
|
|
2020-04-25 08:17:17 +00:00
|
|
|
const { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer')
|
|
|
|
|
2018-10-18 14:36:30 +00:00
|
|
|
const PrerenderSPAPlugin = require('prerender-spa-plugin')
|
2019-03-19 17:50:16 +00:00
|
|
|
|
2018-10-18 14:36:30 +00:00
|
|
|
const Renderer = PrerenderSPAPlugin.PuppeteerRenderer
|
|
|
|
const path = require('path')
|
|
|
|
const cheerio = require('cheerio')
|
|
|
|
const MiniCssExtractPlugin = require('mini-css-extract-plugin')
|
2020-06-03 08:14:09 +00:00
|
|
|
const TerserPlugin = require('terser-webpack-plugin')
|
2018-03-01 18:39:36 +00:00
|
|
|
|
2021-11-02 17:00:44 +00:00
|
|
|
const prerenderConfig = {
|
2018-10-18 14:36:30 +00:00
|
|
|
staticDir: path.resolve('dist'),
|
|
|
|
renderer: new Renderer({
|
|
|
|
renderAfterTime: 5000,
|
2021-05-17 14:29:32 +00:00
|
|
|
inject: true,
|
2020-11-20 18:47:57 +00:00
|
|
|
skipThirdPartyRequests: true,
|
2018-10-18 14:36:30 +00:00
|
|
|
}),
|
2020-11-20 18:47:57 +00:00
|
|
|
postProcess: (context) => {
|
2018-10-18 14:36:30 +00:00
|
|
|
const $ = cheerio.load(context.html)
|
|
|
|
// Remove loader
|
|
|
|
$('#outdated-browser').after(`
|
2019-01-31 16:24:57 +00:00
|
|
|
<style>
|
2018-10-18 14:36:30 +00:00
|
|
|
#js {
|
2021-01-12 14:50:39 +00:00
|
|
|
animation: appear 0.5s;
|
2018-10-18 14:36:30 +00:00
|
|
|
opacity: 1;
|
|
|
|
}
|
2019-08-30 15:16:26 +00:00
|
|
|
#loading {
|
2021-01-12 14:50:39 +00:00
|
|
|
display: none !important;
|
2019-01-31 16:24:57 +00:00
|
|
|
}
|
2018-10-18 14:36:30 +00:00
|
|
|
</style>
|
|
|
|
`)
|
2019-03-19 17:50:16 +00:00
|
|
|
|
2018-10-18 14:36:30 +00:00
|
|
|
context.html = $.html()
|
|
|
|
return context
|
2020-11-20 18:47:57 +00:00
|
|
|
},
|
2021-11-02 17:00:44 +00:00
|
|
|
}
|
2018-11-27 09:55:31 +00:00
|
|
|
|
2018-03-01 18:39:36 +00:00
|
|
|
module.exports = {
|
|
|
|
...common,
|
2019-03-19 17:50:16 +00:00
|
|
|
module: {
|
2020-11-20 18:47:57 +00:00
|
|
|
rules: [...commonLoaders(), styleLoader(MiniCssExtractPlugin.loader)],
|
2019-03-19 17:50:16 +00:00
|
|
|
},
|
|
|
|
output: {
|
|
|
|
...common.output,
|
|
|
|
filename: ({ chunk }) => {
|
2019-04-18 15:42:56 +00:00
|
|
|
return chunk.name === 'simulateur-iframe-integration'
|
2019-03-19 17:50:16 +00:00
|
|
|
? '[name].js'
|
|
|
|
: '[name].[contenthash].bundle.js'
|
2020-11-20 18:47:57 +00:00
|
|
|
},
|
2019-03-19 17:50:16 +00:00
|
|
|
},
|
2018-03-12 15:37:23 +00:00
|
|
|
mode: 'production',
|
2018-08-28 09:53:07 +00:00
|
|
|
devtool: 'source-map',
|
2020-06-03 08:14:09 +00:00
|
|
|
optimization: {
|
|
|
|
minimize: true,
|
|
|
|
minimizer: [
|
|
|
|
new TerserPlugin({
|
2020-11-20 18:47:57 +00:00
|
|
|
parallel: 2,
|
|
|
|
}),
|
|
|
|
],
|
2020-06-03 08:14:09 +00:00
|
|
|
},
|
2018-07-05 16:01:01 +00:00
|
|
|
plugins: [
|
2018-07-05 09:54:41 +00:00
|
|
|
...common.plugins,
|
2019-07-08 09:13:51 +00:00
|
|
|
...HTMLPlugins({ injectTrackingScript: true }),
|
2020-04-25 08:17:17 +00:00
|
|
|
process.env.ANALYZE_BUNDLE && new BundleAnalyzerPlugin(),
|
2021-03-23 07:05:45 +00:00
|
|
|
|
2019-03-19 17:50:16 +00:00
|
|
|
new MiniCssExtractPlugin({
|
|
|
|
// Options similar to the same options in webpackOptions.output
|
|
|
|
// both options are optional
|
|
|
|
filename: '[name].[hash].css',
|
2020-11-20 18:47:57 +00:00
|
|
|
chunkFilename: '[id].[hash].css',
|
2019-03-19 17:50:16 +00:00
|
|
|
}),
|
2020-04-25 08:17:17 +00:00
|
|
|
process.env.ANALYZE_BUNDLE !== '1' &&
|
|
|
|
new PrerenderSPAPlugin({
|
2021-11-02 17:00:44 +00:00
|
|
|
...prerenderConfig,
|
2020-04-25 08:17:17 +00:00
|
|
|
outputDir: path.resolve('dist', 'prerender', 'infrance'),
|
2020-06-25 14:43:09 +00:00
|
|
|
routes: ['/', '/calculators/salary', '/iframes/simulateur-embauche'],
|
2020-11-20 18:47:57 +00:00
|
|
|
indexPath: path.resolve('dist', 'infrance.html'),
|
2020-04-25 08:17:17 +00:00
|
|
|
}),
|
|
|
|
process.env.ANALYZE_BUNDLE !== '1' &&
|
|
|
|
new PrerenderSPAPlugin({
|
2021-11-02 17:00:44 +00:00
|
|
|
...prerenderConfig,
|
2020-04-25 08:17:17 +00:00
|
|
|
outputDir: path.resolve('dist', 'prerender', 'mon-entreprise'),
|
|
|
|
routes: [
|
|
|
|
'/',
|
2021-12-02 12:41:57 +00:00
|
|
|
'/simulateurs',
|
2020-06-25 14:43:09 +00:00
|
|
|
'/simulateurs/salaire-brut-net',
|
2020-04-25 08:17:17 +00:00
|
|
|
'/simulateurs/auto-entrepreneur',
|
|
|
|
'/simulateurs/artiste-auteur',
|
2020-06-25 14:43:09 +00:00
|
|
|
'/simulateurs/dirigeant-sasu',
|
2020-04-25 08:17:17 +00:00
|
|
|
'/simulateurs/indépendant',
|
2020-06-06 07:13:08 +00:00
|
|
|
'/simulateurs/chômage-partiel',
|
2020-04-25 08:17:17 +00:00
|
|
|
'/créer',
|
|
|
|
'/gérer',
|
|
|
|
'/iframes/simulateur-embauche',
|
2020-10-12 13:44:40 +00:00
|
|
|
'/iframes/simulateur-chomage-partiel',
|
2020-11-20 18:47:57 +00:00
|
|
|
'/iframes/pamc',
|
2020-04-25 08:17:17 +00:00
|
|
|
],
|
2020-11-20 18:47:57 +00:00
|
|
|
indexPath: path.resolve('dist', 'mon-entreprise.html'),
|
|
|
|
}),
|
|
|
|
].filter(Boolean),
|
2018-03-01 18:39:36 +00:00
|
|
|
}
|