无法调用Encore.setOutputPath(),因为似乎未配置运行时环境

问题描述 投票:1回答:2

我正在设置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();
reactjs webpack phpstorm webstorm
2个回答
1
投票

PHPStorm目前不支持webpack-encore。

请参阅https://github.com/symfony/webpack-encore/issues/236#issuecomment-438620314以及https://github.com/symfony/webpack-encore/issues/236中的其他评论,以获取可能的解决方法。


0
投票

它失败是因为Encore运行时环境仅在您运行时配置(例如,在执行yarn encore dev时)。修复此问题调用Encore.isRuntimeEnvironmentConfigured()Encore.configureRuntimeEnvironment()方法:

source

// 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
© www.soinside.com 2019 - 2024. All rights reserved.