webpack-encore icon indicating copy to clipboard operation
webpack-encore copied to clipboard

Files missing in entrypoints.json and manifest.json but they where build correctly in producion

Open artur-stepien opened this issue 6 years ago • 1 comments

I got a cms template that is build by Webpack Encore. It needs a main css style file that I can change the name to what ever I like (so I'm versioning that one), and the wysiwyg editor style that has to be called editor.css.

Now. I archived it by using two webpack configurations. The problem is that when it comes to dev environment it works well. Builds the scripts, updates the entrypoints.json and manifest.json and works perfect. But when I make a production build the scripts and styles are build correct without any error but they are missing in entrypoints.json and manifest.json. My fought was that editor config overrides json files generated in first config. So I figured out how to archive versioning in every endpoint except editor css files by using dynamic filenames. Maybe some one will need to solution.

webpack.config.js

var path = require('path');

var templateName = path.basename(__dirname);

var Encore = require('@symfony/webpack-encore');

// Template build configuration
Encore
    .setOutputPath('assets/build')
    .setPublicPath('/templates/'+templateName+'/assets/build')
    .cleanupOutputBeforeBuild()
    .enableBuildNotifications()
    .enableSassLoader()
    .enableVersioning(Encore.isProduction())
    .disableSingleRuntimeChunk()
    .enableSourceMaps(!Encore.isProduction())
    .addExternals({
        jquery: 'jQuery'
    })
    .addEntry('theme',[
        './.dev/sass/index.scss',
        './.dev/js/theme.js'
    ])
    .addEntry('editor',[
        './.dev/sass/editor.scss'
    ])
    .configureFilenames({
        css: function(e) {
            return (e.chunk.id=='editor' ? '[name].css': '[name]-[hash:6].css');
        }
    });

// Export configurations
module.exports = Encore.getWebpackConfig();

artur-stepien avatar Mar 25 '19 12:03 artur-stepien