Lint webpack config

This commit is contained in:
Paul Chavard 2018-09-12 10:40:12 +02:00
parent de102e2323
commit 7c92149066
6 changed files with 28 additions and 16 deletions

View file

@ -14,5 +14,13 @@ module.exports = {
},
rules: {
'prettier/prettier': 'error'
},
overrides: [
{
files: ['config/webpack/*.js'],
env: {
node: true
}
}
]
};

View file

@ -1,5 +1,5 @@
process.env.NODE_ENV = process.env.NODE_ENV || 'development'
process.env.NODE_ENV = process.env.NODE_ENV || 'development';
const environment = require('./environment')
const environment = require('./environment');
module.exports = environment.toWebpackConfig()
module.exports = environment.toWebpackConfig();

View file

@ -1,4 +1,4 @@
const { environment } = require('@rails/webpacker')
const { environment } = require('@rails/webpacker');
// By default don't transpile JS files in ./node_modules except for some specific modules.
const babelLoader = environment.loaders.get('babel');
@ -6,8 +6,12 @@ babelLoader.exclude = function(modulePath) {
let forcedModules = [
'activestorage' // ActiveStorage uses 'class', which is not supported by IE 11 and older Safari version
];
return modulePath.includes('node_modules')
&& forcedModules.every(forcedModule => !modulePath.includes('node_modules/' + forcedModule));
}
return (
modulePath.includes('node_modules') &&
forcedModules.every(
forcedModule => !modulePath.includes('node_modules/' + forcedModule)
)
);
};
module.exports = environment
module.exports = environment;

View file

@ -1,9 +1,9 @@
process.env.NODE_ENV = process.env.NODE_ENV || 'production'
process.env.NODE_ENV = process.env.NODE_ENV || 'production';
const environment = require('./environment')
const environment = require('./environment');
// https://github.com/rails/webpacker/issues/1235
environment.config.optimization.minimizer[0].options.uglifyOptions.ecma = 5; // for IE 11 support
environment.config.optimization.minimizer[0].options.uglifyOptions.safari10 = true;
module.exports = environment.toWebpackConfig()
module.exports = environment.toWebpackConfig();

View file

@ -1,5 +1,5 @@
process.env.NODE_ENV = process.env.NODE_ENV || 'development'
process.env.NODE_ENV = process.env.NODE_ENV || 'development';
const environment = require('./environment')
const environment = require('./environment');
module.exports = environment.toWebpackConfig()
module.exports = environment.toWebpackConfig();

View file

@ -22,7 +22,7 @@
"webpack-dev-server": "^3.1.4"
},
"scripts": {
"lint:js": "eslint ./app/javascript"
"lint:js": "eslint ./app/javascript ./config/webpack"
},
"engines": {
"node": "6.* || 8.* || >= 10.*"