Deshalb möchte ich tun:Webpack config: Bedingter Import-Modul
if (process.env.NODE_ENV === 'production') {
import StatsPlugin from 'webpack-stats-plugin';
}
Aber eslint sagt:
Parsing error: 'import' and 'export' may only appear at the top level
I babel-eslint Parser bin mit.
Impliziert das ich nicht Module bedingt laden kann?
Wenn Sie Module bedingt laden möchten, sollten Sie nur diese Regel deaktivieren. –
Laut ES6 Spezifikation ist dies nicht möglich. Sie könnten stattdessen eine regelmäßige Anforderung versuchen. –
Verwandte, obwohl nicht ein Duplikat: https://stackoverflow.com/questions/36367532/how-can-i-conditional-import-an-es6-module – ericsoco