use*_*454 5 css symfony webpack-dev-server webpack-encore symfony4
从一个新的 Symfony 4 项目中,当我运行这个命令时:
./node_modules/.bin/encore dev-server --hot
Run Code Online (Sandbox Code Playgroud)
然后我修改了一个 scss 文件(通过示例更改 body 标签背景颜色),shell 做出反应
但是我的浏览器不会自动刷新!我总是必须手动重新加载页面以查看最新的 css 更改。我可以在哪里做一个 mystake?
谢谢 !
=> 我用不同的浏览器测试过 => 如果我修改自定义 javascript 文件,浏览器会自动刷新!相反,当我更改 scss 文件时
=> 我的资产目录结构:
=> 我的 webpack.config.js 内容:
var Encore = require('@symfony/webpack-encore');
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/')
/*
* 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')
.addEntry('article/main', './assets/js/article/main.js')
.addStyleEntry('article/style','./assets/css/article/style.scss')
//.addEntry('page2', './assets/js/page2.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())
// enables hashed filenames (e.g. app.abc123.css)
.enableVersioning(Encore.isProduction())
// enables Sass/SCSS support
.enableSassLoader()
// uncomment if you use TypeScript
//.enableTypeScriptLoader()
// uncomment if you're having problems with a jQuery plugin
//.autoProvidejQuery()
;
module.exports = Encore.getWebpackConfig();
Run Code Online (Sandbox Code Playgroud)
=> 我自动生成的 public/build/manifest.json 文件:
| 归档时间: |
|
| 查看次数: |
3501 次 |
| 最近记录: |