Php 带Webpack Encore功能的引导,内部Web服务器为Symfony 4,但不带LAMP
我在Symfony 4项目中使用网页安可。如果我运行php bin/console服务器,则启动函数:运行并转到 但是,当我启动Apache以使用链接引导时,它将停止运行。控制台开发人员给了我:Php 带Webpack Encore功能的引导,内部Web服务器为Symfony 4,但不带LAMP,php,twitter-bootstrap,symfony4,Php,Twitter Bootstrap,Symfony4,我在Symfony 4项目中使用网页安可。如果我运行php bin/console服务器,则启动函数:运行并转到 但是,当我启动Apache以使用链接引导时,它将停止运行。控制台开发人员给了我: The script from “http://localhost/build/runtime.js” was loaded even though its MIME type (“text/html”) is not a valid JavaScript MIME type. 我不明白发生了什么事。
The script from “http://localhost/build/runtime.js” was loaded even though its MIME type (“text/html”) is not a valid JavaScript MIME type.
我不明白发生了什么事。你能帮我吗
Webpack.config.js
var Encore = require('@symfony/webpack-encore');
var CopyWebpackPlugin = require('copy-webpack-plugin'); // this line tell to webpack to use the plugin
Encore
// directory where compiled assets will be stored
.setOutputPath('public/build/')
// public path used by the web server to access the output path
.setPublicPath('/build')
/*
* ENTRY CONFIG
*
* Add 1 entry for each "page" of your app
* (including one that's included on every page - e.g. "app")
*
* Each entry will result in one JavaScript file (e.g. app.js)
* and one CSS file (e.g. app.css) if you JavaScript imports CSS.
*/
.addEntry('app', './assets/js/app.js')
/*
* FEATURE CONFIG
*
* Enable & configure other features below. For a full
* list of features, see:
* https://symfony.com/doc/current/frontend.html#adding-more-features
*/
.cleanupOutputBeforeBuild()
.enableBuildNotifications()
.enableSourceMaps(!Encore.isProduction())
.enableSingleRuntimeChunk()
// enables hashed filenames (e.g. app.abc123.css)
.enableVersioning(Encore.isProduction())
// enables Sass/SCSS support
.enableSassLoader()
// uncomment if you're having problems with a jQuery plugin
.autoProvidejQuery()
.addPlugin(new CopyWebpackPlugin([
{ from: './assets/images', to: 'images' }
]))
;
module.exports = Encore.getWebpackConfig();
在Apache中运行应用程序时,您的公共路径不正确,这会导致无法正确加载资产 由于在本例中您有一个子目录(
显示我的图片
),因此在调用Encore.setPublicPath()时应将其考虑在内:
Encore.setPublicPath(“/show my pictures/build”)
请参阅:您可以发布您的网页配置文件吗?我按照您所说的操作,但它不起作用。纱线安可开发不再运行。它只能与Encore.setPublicPath(“/build”)一起使用。生成文件夹位于公用文件夹下。show my picture是项目的文件夹。你说的“Thread encore dev不再运行”是什么意思?Thread encore dev允许生成css和js文件。对于Encore.setPublicPath('/show my pictures/build'),它不再起作用,我有这样一个问题:Error:无法确定如何在manifest.json中为键添加前缀。调用Encore.setManifestKeyP refix()以选择在生成清单键时要使用的路径(例如build/)。这是由于setOutputPath()(/srv/http/show my pictures/public/build)和setPublicPath()(/sho w-my-pictures/build)包含的路径似乎不兼容造成的。
错误消息中描述了需要执行的操作:“调用Encore.setManifestKeyPrefix()选择路径(例如build/)在生成清单密钥时使用。“。它也出现在我在上面的答案中链接的文档中。在您的情况下,它应该与Encore.setManifestKeyPrefix('build/')
一起使用。请注意,使用此配置时,路径仅适用于Apache。当您说“它不起作用”时,需要更加具体。它现在做什么?你还有错误吗?如果是,是相同的错误吗?