Skip to content

Commit

Permalink
[ESLint] Disable on prod instances
Browse files Browse the repository at this point in the history
  • Loading branch information
laemtl committed Nov 11, 2022
1 parent 8a6086d commit 566f628
Showing 1 changed file with 63 additions and 0 deletions.
63 changes: 63 additions & 0 deletions webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,68 @@ function lorisModule(mname, entries, override=false) {
};
}

let mode = 'production';
try {
const configFile = fs.readFileSync('project/config.xml', 'latin1');
const res = /<[\s]*?sandbox[\s]*?>(.*)<\/[\s]*?sandbox[\s]*?>/
.exec(configFile);
if (res && parseInt(res[1]) == 1) mode = 'development';
} catch (error) {
console.error(
'Error - Can\'t read config.xml file. '
+ 'Webpack mode set to production.'
);
}

const plugins = [
new CopyPlugin({
patterns: [
{
from: path.resolve(__dirname, 'node_modules/react/umd'),
to: path.resolve(__dirname, 'htdocs/vendor/js/react'),
flatten: true,
force: true,
globOptions: {
ignore: ['react.profiling.min.js'],
},
filter: async (path) => {
const file = path.split('\\').pop().split('/').pop();
const keep = [
'react.development.js',
'react.production.min.js',
];
return keep.includes(file);
},
},
{
from: path.resolve(__dirname, 'node_modules/react-dom/umd'),
to: path.resolve(__dirname, 'htdocs/vendor/js/react'),
flatten: true,
force: true,
filter: async (path) => {
const file = path.split('\\').pop().split('/').pop();
const keep = [
'react-dom.development.js',
'react-dom.production.min.js',
];
return keep.includes(file);
},
},
],
}),
];

mode == 'development' && plugins.push(new ESLintPlugin({
files: [
'modules/',
'jsx/',
'jslib/',
'htdocs/js/',
'webpack.config.js',
],
cache: true,
}));

let config = [
// Core components
{
Expand Down Expand Up @@ -227,6 +289,7 @@ let config = [
],
}),
],
plugins: plugins,
optimization: optimization,
resolve: resolve,
module: mod,
Expand Down

0 comments on commit 566f628

Please sign in to comment.