Changeset View
Changeset View
Standalone View
Standalone View
swh/web/assets/config/webpack.config.development.js
Show All 15 Lines | |||||
const RobotstxtPlugin = require('robotstxt-webpack-plugin'); | const RobotstxtPlugin = require('robotstxt-webpack-plugin'); | ||||
const CleanWebpackPlugin = require('clean-webpack-plugin').CleanWebpackPlugin; | const CleanWebpackPlugin = require('clean-webpack-plugin').CleanWebpackPlugin; | ||||
const MiniCssExtractPlugin = require('mini-css-extract-plugin'); | const MiniCssExtractPlugin = require('mini-css-extract-plugin'); | ||||
const FixSwhSourceMapsPlugin = require('./webpack-plugins/fix-swh-source-maps-webpack-plugin'); | const FixSwhSourceMapsPlugin = require('./webpack-plugins/fix-swh-source-maps-webpack-plugin'); | ||||
const CopyWebpackPlugin = require('copy-webpack-plugin'); | const CopyWebpackPlugin = require('copy-webpack-plugin'); | ||||
const GenerateWebLabelsPlugin = require('./webpack-plugins/generate-weblabels-webpack-plugin'); | const GenerateWebLabelsPlugin = require('./webpack-plugins/generate-weblabels-webpack-plugin'); | ||||
const ProgressBarPlugin = require('progress-bar-webpack-plugin'); | const ProgressBarPlugin = require('progress-bar-webpack-plugin'); | ||||
const FixWebpackStatsFormatPlugin = require('./webpack-plugins/fix-webpack-stats-format-plugin'); | const FixWebpackStatsFormatPlugin = require('./webpack-plugins/fix-webpack-stats-format-plugin'); | ||||
const DumpHighlightjsLanguagesDataPlugin = require('./webpack-plugins/dump-highlightjs-languages-data-plugin'); | |||||
// are we running webpack-dev-server ? | // are we running webpack-dev-server ? | ||||
const isDevServer = process.argv.find(v => v.includes('serve')); | const isDevServer = process.argv.find(v => v.includes('serve')); | ||||
// webpack-dev-server configuration | // webpack-dev-server configuration | ||||
const devServerPort = 3000; | const devServerPort = 3000; | ||||
const devServerPublicPath = 'http://localhost:' + devServerPort + '/static/'; | const devServerPublicPath = 'http://localhost:' + devServerPort + '/static/'; | ||||
// set publicPath according if we are using webpack-dev-server to serve | // set publicPath according if we are using webpack-dev-server to serve | ||||
// our assets or not | // our assets or not | ||||
▲ Show 20 Lines • Show All 317 Lines • ▼ Show 20 Lines | noParse: [path.resolve(nodeModules, 'pdfjs-dist/build/pdf.min.js'), | ||||
path.resolve(nodeModules, 'mathjax/es5/tex-mml-chtml.js')] | path.resolve(nodeModules, 'mathjax/es5/tex-mml-chtml.js')] | ||||
}, | }, | ||||
// webpack plugins | // webpack plugins | ||||
plugins: [ | plugins: [ | ||||
// cleanup previously generated assets | // cleanup previously generated assets | ||||
new CleanWebpackPlugin({ | new CleanWebpackPlugin({ | ||||
cleanOnceBeforeBuildPatterns: ['**/*', '!xml', '!xml/*', '!img', '!img/*', | cleanOnceBeforeBuildPatterns: ['**/*', '!xml', '!xml/*', '!img', '!img/*', | ||||
'!img/logos', '!img/logos/*', '!img/icons', | '!img/logos', '!img/logos/*', '!img/icons', | ||||
'!img/icons/*'] | '!img/icons/*', '!json', '!json/*'] | ||||
}), | }), | ||||
// needed in order to use django_webpack_loader | // needed in order to use django_webpack_loader | ||||
new BundleTracker({ | new BundleTracker({ | ||||
path: path.resolve('./static/'), | path: path.resolve('./static/'), | ||||
filename: 'webpack-stats.json' | filename: 'webpack-stats.json' | ||||
}), | }), | ||||
// for generating the robots.txt file | // for generating the robots.txt file | ||||
new RobotstxtPlugin({ | new RobotstxtPlugin({ | ||||
▲ Show 20 Lines • Show All 88 Lines • ▼ Show 20 Lines | new GenerateWebLabelsPlugin({ | ||||
] | ] | ||||
} | } | ||||
) | ) | ||||
}), | }), | ||||
new ProgressBarPlugin({ | new ProgressBarPlugin({ | ||||
format: chalk.cyan.bold('webpack build of swh-web assets') + ' [:bar] ' + chalk.green.bold(':percent') + ' (:elapsed seconds)', | format: chalk.cyan.bold('webpack build of swh-web assets') + ' [:bar] ' + chalk.green.bold(':percent') + ' (:elapsed seconds)', | ||||
width: 50 | width: 50 | ||||
}), | }), | ||||
new FixWebpackStatsFormatPlugin() | new FixWebpackStatsFormatPlugin(), | ||||
new DumpHighlightjsLanguagesDataPlugin() | |||||
], | ], | ||||
// webpack optimizations | // webpack optimizations | ||||
optimization: { | optimization: { | ||||
// ensure the vendors bundle gets emitted in a single chunk | // ensure the vendors bundle gets emitted in a single chunk | ||||
splitChunks: { | splitChunks: { | ||||
cacheGroups: { | cacheGroups: { | ||||
defaultVendors: { | defaultVendors: { | ||||
test: 'vendors', | test: 'vendors', | ||||
Show All 12 Lines |