【发布时间】:2023-03-30 10:12:01
【问题描述】:
这可能更像是一个理论问题,所以我将我的想法写下来......我在我们的 symfony 3.4 应用程序中用 webpack_encore 替换了资产。 Local 一切正常,但是当我通过 Jenkins 将它部署到我们的测试环境时,它会很好地生成所有资产,但是 Entrypoints.json 没有填充入口点信息,而是填充了一个(不存在的)文件。 Jenkins、Composer Install、NPM BUILD 等。一切都没有失败,一切看起来都很好......
我正在与:
- "symfony/symfony": "3.4.*",
- "symfony/webpack-encore-bundle": "^1.4",
- "@symfony/webpack-encore": "^0.26.0";
- 詹金斯版本。 2.167
我做过和检查过的事情:
- webpack_encore 输出路径在 symfony 配置和 webpack.config.js 中设置;
- 设置了读取/写入文件的权限(它们是在每次构建时新生成的)
- 在不同的环境中尝试过(同样的问题,.json 中没有入口点)
- 试图重现 lokal(没有完成)
- 尝试了另一个节点版本(8.x)
这就是 Entrypoints.json 的样子:
{
"entrypoints": {
"main": {
"js": [
"/assets/main.d062ba67.js"
]
}
}
}
这里是生成文件的列表:
-rw-r--r-- 1 deploy deploy 1188442 Apr 4 16:03 0.2d854ee0.js
-rw-r--r-- 1 deploy deploy 13270 Apr 4 16:03 0.e9d891b2.css
-rw-r--r-- 1 deploy deploy 103 Apr 4 16:03 entrypoints.json
drwxr-xr-x 2 deploy deploy 4096 Jan 21 11:04 fonts
drwxr-xr-x 2 deploy deploy 4096 Jan 21 11:04 images
-rw-r--r-- 1 deploy deploy 50 Apr 4 16:03 manifest.json
-rw-r--r-- 1 deploy deploy 273060 Apr 4 16:03 mijn.51e8a5cf.css
-rw-r--r-- 1 deploy deploy 399784 Apr 4 16:03 mijn.b4e892a5.js
-rw-r--r-- 1 deploy deploy 155 Apr 4 16:03 mijn_servicecentre.8ad08279.js
-rw-r--r-- 1 deploy deploy 8867 Apr 4 16:03 mijn_servicecentre.aed8de72.css
-rw-r--r-- 1 deploy deploy 131539 Apr 4 16:03 mijn_translations.6510f7fd.js
-rw-r--r-- 1 deploy deploy 1463 Apr 4 16:03 runtime.3dee20dd.js
编辑:: 最后是 webpack.config.js
/* global __dirname */
let Encore = require("@symfony/webpack-encore");
const path = require("path");
Encore
// output path
.setOutputPath("web/assets")
.enableVersioning()
// relative path in the browser
.setPublicPath("/assets")
// will create web/assets/mijn.js and web/assets/mijn.css && serviceCenter
// which is than included in base.html.twig and respective...
.addEntry("mijn", "./app/Resources/frontend/encore_mijn.js")
.addEntry("mijn_servicecentre", "./app/Resources/frontend/encore_mijn_servicecentre.js")
// enable sass-compilation
.enableSassLoader(function (sassOptions) {
sassOptions.includePaths = [
"node_modules/bootstrap-sass/assets/stylesheets",
"node_modules/bootstrap-datepicker/dist/css",
"node_modules/bootstrap-select/sass",
"node_modules/xs4-icons/dist/"
];
}, {
resolveUrlLoader: true
})
//expose jquery
.addLoader({
test: require.resolve("jquery"),
use: [{
loader: "expose-loader",
options: "jQuery"
}, {
loader: "expose-loader",
options: "$"
}, {
loader: "expose-loader",
options: "Snow"
}]
})
.addLoader({
test: require.resolve("bazinga-translator"),
use: [{
loader: "expose-loader",
options: "Translator"
}],
})
.addLoader({
loader: "webpack-modernizr-loader",
test: /\.modernizrrc\.js$/
})
.addAliases({
modernizr$: path.resolve(__dirname, "./.modernizrrc.js")
})
//enable compilation of vue-components
.enableVueLoader()
//enable sourcemaps for development reasons only
.enableSourceMaps(!Encore.isProduction())
// enable postcss loader for autoprefixing
.enablePostCssLoader()
// empty the outputPath dir before each build
.cleanupOutputBeforeBuild()
.enableSingleRuntimeChunk()
.enableSingleRuntimeChunk()
.splitEntryChunks()
;
// isProduction because we get in dev-mode real-time translation
// out of _translations.html.twig and the bazinga vendor plugin
if (Encore.isProduction()) {
Encore.addEntry("mijn_translations", "./app/Resources/frontend/encore_translations.js")
}
// export the final configuration
module.exports = Encore.getWebpackConfig();
是否有人想过,入口点文件如何生成得很好,但入口点.json 没有填充?
编辑 2::
我再次运行我的所有提交,看起来自从我升级了 npm 包:webpack-encore 从 0.20.1 到 0.21 这需要 babel7 打破...
【问题讨论】:
-
也显示你的 webpack.config.js 文件
标签: symfony jenkins webpack webpack-encore