这可能是一个理论上的问题,所以我只写下我的想法...在symfony 3.4应用程序中,我用webpack_encore替换了资产。 Local可以正常运行,但是当我通过Jenkins将其部署到我们的测试环境时,它可以很好地生成所有资产,但是Entrypoints.json并不填充入口点信息,而是填充了一个(不存在)文件。 Jenkins,Composer Install,NPM BUILD等。一切正常,一切都很好...
我正在与
我已完成并检查的事情:
这就是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();
有人想出如何生成入口点文件就可以了,但是Entrypoints.json却没有被填充吗?
编辑2 ::
我再次遍历了所有提交,并且看起来好像我升级了npm软件包:webpack-encore从0.20.1升级到0.21一样需要babel7打破...
答案 0 :(得分:0)
除了您的双.enableSingleRuntimeChunk()
行,这只是一个错字(,但您永远不知道,这可能是罪魁祸首),我认为您想看看{{1 }}文件,以使您的实际文件和入口点之间具有匹配项。
我不知道您到底要用manifest.json
文件来实现什么,但正如 stof 所说:“ 您仍应使用entrypoints.json
找到每个版本的路径”(在https://github.com/symfony/webpack-encore/issues/355中)