我正在设置webpack.config.js但是我错过了setOutputPath()
函数的警告PhpStorm消息
我有PhpStorm的2018.3.2版本,我在Linux Debian工作
let Encore = require('@symfony/webpack-encore');
Encore
.setOutputPath('public/build/')
.setPublicPath('/build')
.addEntry('app', './assets/js/app.js')
.splitEntryChunks()
.enableSingleRuntimeChunk()
.cleanupOutputBeforeBuild()
.enableBuildNotifications()
.enableSourceMaps(!Encore.isProduction())
.enableVersioning(Encore.isProduction())
.enableReactPreset()
.configureBabel(function (babelConfig) {
babelConfig.presets.push('@babel/preset-flow');
babelConfig.plugins.push("@babel/plugin-proposal-class-properties");
babelConfig.plugins.push('styled-jsx/babel');
});
module.exports = Encore.getWebpackConfig();
PHPStorm目前不支持webpack-encore。
请参阅https://github.com/symfony/webpack-encore/issues/236#issuecomment-438620314以及https://github.com/symfony/webpack-encore/issues/236中的其他评论,以获取可能的解决方法。
它失败是因为Encore运行时环境仅在您运行时配置(例如,在执行
yarn encore dev
时)。修复此问题调用Encore.isRuntimeEnvironmentConfigured()
和Encore.configureRuntimeEnvironment()
方法:
// webpack.config.js
const Encore = require('@symfony/webpack-encore')
if (!Encore.isRuntimeEnvironmentConfigured()) {
Encore.configureRuntimeEnvironment(process.env.NODE_ENV || 'dev');
}
// ... the rest of the Encore configuration