@ -1,12 +1,10 @@
const cssnano = require ( 'cssnano' ) ;
const fastGlob = require ( 'fast-glob' ) ;
const fastGlob = require ( 'fast-glob' ) ;
const wrapAnsi = require ( 'wrap-ansi' ) ;
const wrapAnsi = require ( 'wrap-ansi' ) ;
const CssNanoPlugin = require ( 'cssnano-webpack-plugin' ) ;
const FixStyleOnlyEntriesPlugin = require ( 'webpack-fix-style-only-entries' ) ;
const FixStyleOnlyEntriesPlugin = require ( 'webpack-fix-style-only-entries' ) ;
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 OptimizeCSSAssetsPlugin = require ( 'optimize-css-assets-webpack-plugin' ) ;
const PostCSSPresetEnv = require ( 'postcss-preset-env' ) ;
const PostCSSPresetEnv = require ( 'postcss-preset-env' ) ;
const PostCSSSafeParser = require ( 'postcss-safe-parser' ) ;
const SpriteLoaderPlugin = require ( 'svg-sprite-loader/plugin' ) ;
const SpriteLoaderPlugin = require ( 'svg-sprite-loader/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' ) ;
@ -24,19 +22,31 @@ for (const path of glob('web_src/less/themes/*.less')) {
const isProduction = process . env . NODE _ENV !== 'development' ;
const isProduction = process . env . NODE _ENV !== 'development' ;
const filterCssImport = ( parsedImport , cssFile ) => {
const url = parsedImport && parsedImport . url ? parsedImport . url : parsedImport ;
const importedFile = url . replace ( /[?#].+/ , '' ) . toLowerCase ( ) ;
if ( cssFile . includes ( 'monaco' ) ) return true ;
if ( cssFile . includes ( 'fomantic' ) ) {
if ( /brand-icons/ . test ( importedFile ) ) return false ;
if ( /(eot|ttf|woff)$/ . test ( importedFile ) ) return false ;
return true ;
}
return cssFile . includes ( 'node_modules' ) ;
} ;
module . exports = {
module . exports = {
mode : isProduction ? 'production' : 'development' ,
mode : isProduction ? 'production' : 'development' ,
entry : {
entry : {
index : [
index : [
resolve ( _ _dirname , 'web_src/js/jquery.js' ) ,
resolve ( _ _dirname , 'web_src/fomantic/build/semantic.js' ) ,
resolve ( _ _dirname , 'web_src/js/index.js' ) ,
resolve ( _ _dirname , 'web_src/js/index.js' ) ,
resolve ( _ _dirname , 'web_src/fomantic/build/semantic.css' ) ,
resolve ( _ _dirname , 'web_src/less/index.less' ) ,
resolve ( _ _dirname , 'web_src/less/index.less' ) ,
] ,
] ,
swagger : [
swagger : [
resolve ( _ _dirname , 'web_src/js/standalone/swagger.js' ) ,
resolve ( _ _dirname , 'web_src/js/standalone/swagger.js' ) ,
] ,
] ,
jquery : [
resolve ( _ _dirname , 'web_src/js/jquery.js' ) ,
] ,
serviceworker : [
serviceworker : [
resolve ( _ _dirname , 'web_src/js/serviceworker.js' ) ,
resolve ( _ _dirname , 'web_src/js/serviceworker.js' ) ,
] ,
] ,
@ -66,12 +76,9 @@ module.exports = {
} ,
} ,
} ,
} ,
} ) ,
} ) ,
new OptimizeCSSAssetsPlugin ( {
new CssNanoPlugin ( {
cssProcessor : cssnano ,
sourceMap : true ,
cssProcessorOptions : {
cssnanoOptions : {
parser : PostCSSSafeParser ,
} ,
cssProcessorPluginOptions : {
preset : [
preset : [
'default' ,
'default' ,
{
{
@ -91,10 +98,10 @@ module.exports = {
monaco : {
monaco : {
test : /monaco-editor/ ,
test : /monaco-editor/ ,
name : 'monaco' ,
name : 'monaco' ,
chunks : 'async'
chunks : 'async' ,
}
} ,
}
} ,
}
} ,
} ,
} ,
module : {
module : {
rules : [
rules : [
@ -150,12 +157,41 @@ module.exports = {
] ,
] ,
'@babel/plugin-proposal-object-rest-spread' ,
'@babel/plugin-proposal-object-rest-spread' ,
] ,
] ,
generatorOpts : {
compact : false ,
} ,
} ,
} ,
} ,
} ,
] ,
] ,
} ,
} ,
{
{
test : /\.(less|css)$/i ,
test : /.css$/i ,
use : [
{
loader : MiniCssExtractPlugin . loader ,
} ,
{
loader : 'css-loader' ,
options : {
importLoaders : 1 ,
url : filterCssImport ,
import : filterCssImport ,
sourceMap : true ,
} ,
} ,
{
loader : 'postcss-loader' ,
options : {
plugins : ( ) => [
PostCSSPresetEnv ( ) ,
] ,
sourceMap : true ,
} ,
} ,
] ,
} ,
{
test : /.less$/i ,
use : [
use : [
{
{
loader : MiniCssExtractPlugin . loader ,
loader : MiniCssExtractPlugin . loader ,
@ -164,11 +200,10 @@ module.exports = {
loader : 'css-loader' ,
loader : 'css-loader' ,
options : {
options : {
importLoaders : 2 ,
importLoaders : 2 ,
url : ( _url , resourcePath ) => {
url : filterCssImport ,
// only resolve URLs for dependencies
import : filterCssImport ,
return resourcePath . includes ( 'node_modules' ) ;
sourceMap : true ,
} ,
} ,
}
} ,
} ,
{
{
loader : 'postcss-loader' ,
loader : 'postcss-loader' ,
@ -176,10 +211,14 @@ module.exports = {
plugins : ( ) => [
plugins : ( ) => [
PostCSSPresetEnv ( ) ,
PostCSSPresetEnv ( ) ,
] ,
] ,
sourceMap : true ,
} ,
} ,
} ,
} ,
{
{
loader : 'less-loader' ,
loader : 'less-loader' ,
options : {
sourceMap : true ,
} ,
} ,
} ,
] ,
] ,
} ,
} ,
@ -232,9 +271,10 @@ module.exports = {
chunkFilename : 'css/[name].css' ,
chunkFilename : 'css/[name].css' ,
} ) ,
} ) ,
new SourceMapDevToolPlugin ( {
new SourceMapDevToolPlugin ( {
filename : 'js/[name].js .map' ,
filename : '[file] .map' ,
include : [
include : [
'js/index.js' ,
'js/index.js' ,
'css/index.css' ,
] ,
] ,
} ) ,
} ) ,
new SpriteLoaderPlugin ( {
new SpriteLoaderPlugin ( {
@ -251,12 +291,6 @@ module.exports = {
modulesDirectories : [
modulesDirectories : [
resolve ( _ _dirname , 'node_modules' ) ,
resolve ( _ _dirname , 'node_modules' ) ,
] ,
] ,
additionalModules : [
{
name : 'fomantic-ui' ,
directory : resolve ( _ _dirname , 'node_modules/fomantic-ui' ) ,
} ,
] ,
renderLicenses : ( modules ) => {
renderLicenses : ( modules ) => {
const line = '-' . repeat ( 80 ) ;
const line = '-' . repeat ( 80 ) ;
return modules . map ( ( module ) => {
return modules . map ( ( module ) => {