Symfony4,无法使用webpack缩小CSS

时间:2019-01-09 23:43:55

标签: webpack minify symfony4

我有一个symfony 4 Web应用程序,我试图缩小CSS,但是它不起作用。我已经尝试了好几个小时,但我无法让它提供缩小版。我在做错什么吗?

webpack.config.js

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

Encore
    // the project directory where compiled assets will be stored
    .setOutputPath('public/build/')
   // the public path used by the web server to access the previous 
directory
    .setPublicPath('/build')
    .cleanupOutputBeforeBuild()
    .enableSourceMaps(!Encore.isProduction())

    .splitEntryChunks()
    .enableSingleRuntimeChunk()
    .enablePostCssLoader()


    // uncomment to create hashed filenames (e.g. app.abc123.css)
    // .enableVersioning(Encore.isProduction())

    // uncomment to define the assets of the project
     .addEntry('js/app', './assets/js/app.js')
    // .addStyleEntry('css/app', './assets/css/app.scss')

    // uncomment if you use Sass/SCSS files
    // .enableSassLoader()

    // uncomment for legacy applications that require $/jQuery as a 
global variable
    // .autoProvidejQuery()



;


module.exports = Encore.getWebpackConfig();

postcss.config.js

module.exports = {
    plugins: {
        // include whatever plugins you want
        // but make sure you install these via yarn or npm!

        // add browserslist config to package.json (see below)
        autoprefixer: {}
    }
}

1 个答案:

答案 0 :(得分:1)

您需要使用yarn encore production编译资产以进行生产

我不确定,但是npm encore production./node_modules/.bin/encore production也应该起作用。