gpt4 book ai didi

reactjs - 还不能调用 Encore.setOutputPath() 因为运行时环境似乎没有配置

转载 作者:行者123 更新时间:2023-12-01 06:12:56 25 4
gpt4 key购买 nike

我正在设置 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();

最佳答案

It fails because the Encore Runtime Environment is only configured when you are running it (e.g. when executing yarn encore dev). Fix this issue calling to Encore.isRuntimeEnvironmentConfigured() and Encore.configureRuntimeEnvironment() methods:



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

关于reactjs - 还不能调用 Encore.setOutputPath() 因为运行时环境似乎没有配置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55456092/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com