@ -2,14 +2,13 @@ const fastGlob = require('fast-glob');
const wrapAnsi = require ( 'wrap-ansi' ) ;
const wrapAnsi = require ( 'wrap-ansi' ) ;
const AddAssetPlugin = require ( 'add-asset-webpack-plugin' ) ;
const AddAssetPlugin = require ( 'add-asset-webpack-plugin' ) ;
const CssMinimizerPlugin = require ( 'css-minimizer-webpack-plugin' ) ;
const CssMinimizerPlugin = require ( 'css-minimizer-webpack-plugin' ) ;
const FixStyleOnlyEntries Plugin = require ( 'webpack-fix-style-only-entries ' ) ;
const LicenseCheckerWebpack Plugin = require ( 'license-checker-webpack-plugin ' ) ;
const MiniCssExtractPlugin = require ( 'mini-css-extract-plugin' ) ;
const MiniCssExtractPlugin = require ( 'mini-css-extract-plugin' ) ;
const MonacoWebpackPlugin = require ( 'monaco-editor-webpack-plugin' ) ;
const MonacoWebpackPlugin = require ( 'monaco-editor-webpack-plugin' ) ;
const TerserPlugin = require ( 'terser-webpack-plugin' ) ;
const TerserPlugin = require ( 'terser-webpack-plugin' ) ;
const VueLoaderPlugin = require ( 'vue-loader/lib/plugin' ) ;
const VueLoaderPlugin = require ( 'vue-loader/lib/plugin' ) ;
const { statSync } = require ( 'fs' ) ;
const { statSync } = require ( 'fs' ) ;
const { resolve , parse } = require ( 'path' ) ;
const { resolve , parse } = require ( 'path' ) ;
const { LicenseWebpackPlugin } = require ( 'license-webpack-plugin' ) ;
const { SourceMapDevToolPlugin } = require ( 'webpack' ) ;
const { SourceMapDevToolPlugin } = require ( 'webpack' ) ;
const glob = ( pattern ) => fastGlob . sync ( pattern , { cwd : _ _dirname , absolute : true } ) ;
const glob = ( pattern ) => fastGlob . sync ( pattern , { cwd : _ _dirname , absolute : true } ) ;
@ -30,8 +29,8 @@ const filterCssImport = (url, ...args) => {
if ( /(eot|ttf|otf|woff|svg)$/ . test ( importedFile ) ) return false ;
if ( /(eot|ttf|otf|woff|svg)$/ . test ( importedFile ) ) return false ;
}
}
if ( cssFile . includes ( 'font-awesome' ) ) {
if ( cssFile . includes ( 'font-awesome' ) && /(eot|ttf|otf|woff|svg)$/ . test ( importedFile ) ) {
if ( /(eot|ttf|otf|woff|svg)$/ . test ( importedFile ) ) return false ;
return false ;
}
}
return true ;
return true ;
@ -71,13 +70,15 @@ module.exports = {
// we have to put it in / instead of /js/
// we have to put it in / instead of /js/
return chunk . name === 'serviceworker' ? '[name].js' : 'js/[name].js' ;
return chunk . name === 'serviceworker' ? '[name].js' : 'js/[name].js' ;
} ,
} ,
chunkFilename : 'js/[name].js' ,
chunkFilename : ( { chunk } ) => {
const language = ( /monaco.*languages?_.+?_(.+?)_/ . exec ( chunk . id ) || [ ] ) [ 1 ] ;
return language ? ` js/monaco-language- ${ language . toLowerCase ( ) } .js ` : ` js/[name].js ` ;
} ,
} ,
} ,
optimization : {
optimization : {
minimize : isProduction ,
minimize : isProduction ,
minimizer : [
minimizer : [
new TerserPlugin ( {
new TerserPlugin ( {
sourceMap : true ,
extractComments : false ,
extractComments : false ,
terserOptions : {
terserOptions : {
output : {
output : {
@ -103,6 +104,8 @@ module.exports = {
chunks : 'async' ,
chunks : 'async' ,
name : ( _ , chunks ) => chunks . map ( ( item ) => item . name ) . join ( '-' ) ,
name : ( _ , chunks ) => chunks . map ( ( item ) => item . name ) . join ( '-' ) ,
} ,
} ,
moduleIds : 'named' ,
chunkIds : 'named' ,
} ,
} ,
module : {
module : {
rules : [
rules : [
@ -240,11 +243,6 @@ module.exports = {
} ,
} ,
plugins : [
plugins : [
new VueLoaderPlugin ( ) ,
new VueLoaderPlugin ( ) ,
// avoid generating useless js output files for css--only chunks
new FixStyleOnlyEntriesPlugin ( {
extensions : [ 'less' , 'scss' , 'css' ] ,
silent : true ,
} ) ,
new MiniCssExtractPlugin ( {
new MiniCssExtractPlugin ( {
filename : 'css/[name].css' ,
filename : 'css/[name].css' ,
chunkFilename : 'css/[name].css' ,
chunkFilename : 'css/[name].css' ,
@ -259,29 +257,18 @@ module.exports = {
new MonacoWebpackPlugin ( {
new MonacoWebpackPlugin ( {
filename : 'js/monaco-[name].worker.js' ,
filename : 'js/monaco-[name].worker.js' ,
} ) ,
} ) ,
isProduction ? new LicenseWebpackPlugin ( {
isProduction ? new LicenseChecker WebpackPlugin ( {
outputFilename : 'js/licenses.txt' ,
outputFilename : 'js/licenses.txt' ,
perChunkOutput : false ,
outputWriter : ( { dependencies } ) => {
addBanner : false ,
skipChildCompilers : true ,
modulesDirectories : [
resolve ( _ _dirname , 'node_modules' ) ,
] ,
additionalModules : [
'@primer/octicons' ,
] . map ( ( name ) => ( { name , directory : resolve ( _ _dirname , ` node_modules/ ${ name } ` ) } ) ) ,
renderLicenses : ( modules ) => {
const line = '-' . repeat ( 80 ) ;
const line = '-' . repeat ( 80 ) ;
return modules . map ( ( module ) => {
return dependencies . map ( ( module ) => {
const { name , version } = module . packageJson ;
const { name , version , licenseName , licenseText } = module ;
const { licenseId , licenseText } = module ;
const body = wrapAnsi ( licenseText || '' , 80 ) ;
const body = wrapAnsi ( licenseText || '' , 80 ) ;
return ` ${ line } \n ${ name } @ ${ version } - ${ licenseId } \n ${ line } \n ${ body } ` ;
return ` ${ line } \n ${ name } @ ${ version } - ${ licenseName } \n ${ line } \n ${ body } ` ;
} ) . join ( '\n' ) ;
} ) . join ( '\n' ) ;
} ,
} ,
stats : {
override : {
warnings : false ,
'jquery.are-you-sure@*' : { licenseName : 'MIT' } ,
errors : true ,
} ,
} ,
} ) : new AddAssetPlugin ( 'js/licenses.txt' , ` Licenses are disabled during development ` ) ,
} ) : new AddAssetPlugin ( 'js/licenses.txt' , ` Licenses are disabled during development ` ) ,
] ,
] ,
@ -302,11 +289,26 @@ module.exports = {
] ,
] ,
} ,
} ,
stats : {
stats : {
assetsSort : 'name' ,
assetsSpace : Infinity ,
cached : false ,
cachedModules : false ,
children : false ,
children : false ,
chunkModules : false ,
chunkOrigins : false ,
chunksSort : 'name' ,
colors : true ,
entrypoints : false ,
excludeAssets : [
excludeAssets : [
// exclude monaco's language chunks in stats output for brevity
/^js\/monaco-language-.+\.js$/ ,
// https://github.com/microsoft/monaco-editor-webpack-plugin/issues/113
! isProduction && /^js\/licenses.txt$/ ,
/^js\/[0-9]+\.js$/ ,
] . filter ( ( item ) => ! ! item ) ,
] ,
groupAssetsByChunk : false ,
groupAssetsByEmitStatus : false ,
groupAssetsByInfo : false ,
groupModulesByAttributes : false ,
modules : false ,
reasons : false ,
runtimeModules : false ,
} ,
} ,
} ;
} ;