Sir*_*haa 7 symfony webpack-dev-server webpack-encore
我想指出的是,我使用的是带有 Webpack 默认配置的经典 Symfony 应用程序。而且 watch 命令运行得非常好。
您好,当我尝试启动 Webpack Encore 开发服务器时,编译没有任何问题,但当我访问页面时,出现错误“Cannot GET /”。我在控制台中没有错误

(来源:casimages.com)
但有趣的是,http://localhost:8000/webpack-dev-server似乎有效。

(来源:casimages.com)
var Encore = require('@symfony/webpack-encore');
if (!Encore.isRuntimeEnvironmentConfigured()) {
Encore.configureRuntimeEnvironment(process.env.NODE_ENV || 'dev');
}
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')
// only needed for CDN's or sub-directory deploy
//.setManifestKeyPrefix('build/')ne CSS file (e.g. app.css) if your JavaScript imports CSS.
*/
.addEntry('app', './assets/js/app.js')
//.addEntry('page1', './assets/js/page1.js')
//.addEntry('page2', './assets/js/page2.js')
.splitEntryChunks()
.enableSingleRuntimeChunk()
.cleanupOutputBeforeBuild()
.enableBuildNotifications()
.enableSourceMaps(!Encore.isProduction())
// enables hashed filenames (e.g. app.abc123.css)
.enableVersioning(Encore.isProduction())
.configureBabel(() => {}, {
useBuiltIns: 'usage',
corejs: 3
})
//.enableSassLoader()
//.enableTypeScriptLoader()
//.enableIntegrityHashes(Encore.isProduction())
.autoProvidejQuery()
.autoProvideVariables({
$: 'jquery',
jQuery: 'jquery',
'window.jQuery': 'jquery',
})
.enableReactPreset()
;
module.exports = Encore.getWebpackConfig();
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2391 次 |
| 最近记录: |