Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions config/entries.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module.exports = {
app: ['./src/js/index.js', './src/scss/style.scss'],
editor: ['./src/js/editor.js', './src/scss/editor.scss'],
'post-build': './src/js/post-build.js',
login: './src/scss/login.scss',
app: ['./src/js/index.js', './src/scss/style.scss'],
editor: ['./src/js/editor.js', './src/scss/editor.scss'],
'post-build': './src/js/post-build.js',
login: './src/scss/login.scss',
}
222 changes: 111 additions & 111 deletions config/loaders.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,123 +5,123 @@ const nodeModulesPath = path.resolve(__dirname, '../node_modules')
const browserslistConfig = require('@wordpress/browserslist-config')

function isEditor(loaderContext) {
return loaderContext.resource.indexOf('editor.scss') > -1
return loaderContext.resource.indexOf('editor.scss') > -1
}

module.exports = {
get: function (mode) {
const isProduction = mode === 'production'
get: function (mode) {
const isProduction = mode === 'production'

return [
/* FontsLoader */ {
test: /\.(woff|woff2)$/,
type: 'asset/resource',
include: [srcPath + '/fonts', nodeModulesPath + '/@fontsource-variable', nodeModulesPath + '/@fontsource'],
generator: {
filename: 'fonts/[name][ext][query]',
},
},
/* ImagesLoader */ {
test: /\.(png|jpe?g|gif|svg|avif|webp)$/,
type: 'asset/resource',
exclude: /icons/,
include: srcPath + '/img',
generator: {
filename: 'images/[name][ext][query]',
},
},
/* JSLoader */ {
test: /\.js$/i,
include: srcPath + '/js',
use: {
loader: 'esbuild-loader',
options: {
loader: 'js',
target: 'es2016',
legalComments: 'inline',
},
},
},
/* SCSSLoader */ {
test: /\.(scss|css)$/,
include: srcPath + '/scss',
use: [
MiniCssExtractPlugin.loader,
{
loader: 'css-loader',
options: {
url: true,
esModule: false,
importLoaders: 1,
},
},
{
loader: 'postcss-loader',
options: {
postcssOptions: function (loaderContext) {
let obj = {
plugins: {
'postcss-import': {},
'postcss-preset-env': {
browsers: browserslistConfig,
stage: 2,
features: {
// https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_logical_properties_and_values
// https://stackoverflow.com/questions/64565180/how-to-prevent-postcss-preset-env-from-removing-css-logical-properties#answer-66966232
// Use stage 2 features + disable logical properties and values rule
'logical-properties-and-values': false,
},
},
'postcss-pxtorem': { propWhiteList: [] },
'postcss-sort-media-queries': {},
},
}
return [
/* FontsLoader */ {
test: /\.(woff|woff2)$/,
type: 'asset/resource',
include: [srcPath + '/fonts', nodeModulesPath + '/@fontsource-variable', nodeModulesPath + '/@fontsource'],
generator: {
filename: 'fonts/[name][ext][query]',
},
},
/* ImagesLoader */ {
test: /\.(png|jpe?g|gif|svg|avif|webp)$/,
type: 'asset/resource',
exclude: /icons/,
include: srcPath + '/img',
generator: {
filename: 'images/[name][ext][query]',
},
},
/* JSLoader */ {
test: /\.js$/i,
include: srcPath + '/js',
use: {
loader: 'esbuild-loader',
options: {
loader: 'js',
target: 'es2016',
legalComments: 'inline',
},
},
},
/* SCSSLoader */ {
test: /\.(scss|css)$/,
include: srcPath + '/scss',
use: [
MiniCssExtractPlugin.loader,
{
loader: 'css-loader',
options: {
url: true,
esModule: false,
importLoaders: 1,
},
},
{
loader: 'postcss-loader',
options: {
postcssOptions: function (loaderContext) {
let obj = {
plugins: {
'postcss-import': {},
'postcss-preset-env': {
browsers: browserslistConfig,
stage: 2,
features: {
// https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_logical_properties_and_values
// https://stackoverflow.com/questions/64565180/how-to-prevent-postcss-preset-env-from-removing-css-logical-properties#answer-66966232
// Use stage 2 features + disable logical properties and values rule
'logical-properties-and-values': false,
},
},
'postcss-pxtorem': { propWhiteList: [] },
'postcss-sort-media-queries': {},
},
}

if (isProduction && !isEditor(loaderContext)) {
obj.plugins.cssnano = {}
}
if (isProduction && !isEditor(loaderContext)) {
obj.plugins.cssnano = {}
}

return obj
},
},
},
{
loader: 'sass-loader',
options: {
sassOptions: function (loaderContext) {
let obj = {
quietDeps: true,
sourceMap: true,
}
return obj
},
},
},
{
loader: 'sass-loader',
options: {
sassOptions: function (loaderContext) {
let obj = {
quietDeps: true,
sourceMap: true,
}

if (isProduction && isEditor(loaderContext)) {
obj.outputStyle = 'expanded'
}
if (isProduction && isEditor(loaderContext)) {
obj.outputStyle = 'expanded'
}

return obj
},
},
},
],
},
/* SVGLoader */ {
test: /\.svg$/,
include: srcPath + '/img/icons',
use: [
{
loader: 'svg-sprite-loader',
options: {
extract: true,
publicPath: 'icons/',
spriteFilename: (svgPath) => `${/icons([\\|/])(.*?)\1/gm.exec(svgPath)[2]}.svg`,
symbolId: (filePath) => `icon-${path.basename(filePath).slice(0, -4)}`,
},
},
{
loader: 'svgo-loader',
},
],
},
]
},
return obj
},
},
},
],
},
/* SVGLoader */ {
test: /\.svg$/,
include: srcPath + '/img/icons',
use: [
{
loader: 'svg-sprite-loader',
options: {
extract: true,
publicPath: 'icons/',
spriteFilename: (svgPath) => `${/icons([\\|/])(.*?)\1/gm.exec(svgPath)[2]}.svg`,
symbolId: (filePath) => `icon-${path.basename(filePath).slice(0, -4)}`,
},
},
{
loader: 'svgo-loader',
},
],
},
]
},
}
72 changes: 36 additions & 36 deletions config/svgo.config.js
Original file line number Diff line number Diff line change
@@ -1,38 +1,38 @@
module.exports = {
plugins: [
{ cleanupAttrs: true },
{ removeDoctype: true },
{ removeXMLProcInst: true },
{ removeComments: true },
{ removeMetadata: true },
{ removeTitle: true },
{ removeDesc: true },
{ removeUselessDefs: true },
{ removeEditorsNSData: true },
{ removeEmptyAttrs: true },
{ removeHiddenElems: true },
{ removeEmptyText: true },
{ removeEmptyContainers: true },
{ cleanupEnableBackground: true },
{ convertStyleToAttrs: true },
{ convertColors: true },
{ convertPathData: true },
{ convertTransform: true },
{ removeUnknownsAndDefaults: true },
{ removeNonInheritableGroupAttrs: true },
{ removeUselessStrokeAndFill: true },
{ removeUnusedNS: true },
{ cleanupIDs: true },
{ cleanupNumericValues: true },
{ moveElemsAttrsToGroup: true },
{ moveGroupAttrsToElems: true },
{ collapseGroups: true },
{ removeRasterImages: false },
{ mergePaths: true },
{ convertShapeToPath: true },
{ sortAttrs: true },
{ removeDimensions: false },
{ prefixIds: true },
{ removeViewBox: false },
],
plugins: [
{ cleanupAttrs: true },
{ removeDoctype: true },
{ removeXMLProcInst: true },
{ removeComments: true },
{ removeMetadata: true },
{ removeTitle: true },
{ removeDesc: true },
{ removeUselessDefs: true },
{ removeEditorsNSData: true },
{ removeEmptyAttrs: true },
{ removeHiddenElems: true },
{ removeEmptyText: true },
{ removeEmptyContainers: true },
{ cleanupEnableBackground: true },
{ convertStyleToAttrs: true },
{ convertColors: true },
{ convertPathData: true },
{ convertTransform: true },
{ removeUnknownsAndDefaults: true },
{ removeNonInheritableGroupAttrs: true },
{ removeUselessStrokeAndFill: true },
{ removeUnusedNS: true },
{ cleanupIDs: true },
{ cleanupNumericValues: true },
{ moveElemsAttrsToGroup: true },
{ moveGroupAttrsToElems: true },
{ collapseGroups: true },
{ removeRasterImages: false },
{ mergePaths: true },
{ convertShapeToPath: true },
{ sortAttrs: true },
{ removeDimensions: false },
{ prefixIds: true },
{ removeViewBox: false },
],
}
Loading