简体   繁体   English

我只能将js文件与encore结合起来吗?

[英]Can I only combine js files with encore?

I have symfony project with twitter bootstrap template (hardcoded assets in twig).我有 symfony 项目和 twitter 引导模板(树枝中的硬编码资产)。 I would like manage assets with Encore, but if encore process file, make module and next compilation magic.我想用 Encore 管理资产,但如果 encore 处理文件,则制作模块和下一个编译魔法。

Is any way how to config Encore for only combine js, without compilation?有什么方法可以配置 Encore 只组合 js,而不进行编译?

Basic install Encore: https://symfony.com/doc/current/frontend/encore/installation.html基本安装 Encore: https://symfony.com/doc/current/frontend/encore/installation.html

...and my idea, in file app.js: ...和我的想法,在文件 app.js 中:

include '1-file.js'; // alert(1);
include '2-file.js'; // alert(2);

and output in twig:和 twig 中的 output:

merged.js // alert(1); alert(2);

thanks for any advice感谢您的建议

I have been working with encore for many months, when you run yarn build or npm run build , encore minimize those files.我已经使用 encore 好几个月了,当您运行yarn buildnpm run build时,encore 将这些文件最小化。 In webpack.config.js you have an option called enableSingleRuntimeChunk().webpack.config.js中有一个名为 enableSingleRuntimeChunk() 的选项。 This option says to the system that, in case of a big file, encore will split the file in two for optimize the process.此选项告诉系统,如果文件很大,encore 会将文件一分为二以优化流程。 If you want to disable, remove the previous line and write.disableSingleRuntimeChunk().如果要禁用,请删除上一行并 write.disableSingleRuntimeChunk()。

Don't forget to run encore again to save this changes!!不要忘记再次运行 encore 以保存此更改!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM