gabiseabra / google-fonts-webpack-plugin

131 stars 44 forks source link

Webpack Encore - minifying and versioning ??? #17

Open Ppito opened 6 years ago

Ppito commented 6 years ago

Hello,

I need some help, I want to use your plugins with Webpack Encore, but the versioning and minifying not process the generated files, any ideas ?

Config :

// webpack.config.js

let Encore            = require('@symfony/webpack-encore');
let GoogleFontsPlugin = require("google-fonts-webpack-plugin");

Encore
// directory where all compiled assets will be stored
    .setOutputPath('./www/build/')

    // what's the public path to this directory (relative to your project's document root dir)
    .setPublicPath('/build')

    // // empty the outputPath dir before each build
    .cleanupOutputBeforeBuild()

    .addPlugin(new GoogleFontsPlugin({
        fonts: [
            { family: "Roboto", variants: [ "300", "700", "300italic", "700italic" ] },
            { family: "Roboto Slab", variants: ["700" ] },
        ],
        "path": "fonts/",
        "filename": "css/google-fonts.css"
    }))

    // will output as web/build/global.css
    .addStyleEntry('css/style', './www/css/styles.css')

    .enableSourceMaps(!Encore.isProduction())

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

// export the final configuration
module.exports = Encore.getWebpackConfig();

Command :

yarn encore production

I even tried to add .addStyleEntry('css/google-fonts.min', './www/build/css/google-fonts.css') in the configuration but Webpack throw this error :

Entry module not found: Error: Can't resolve './www/build/css/google-fonts.css' in '/home/XXX'

JohJohan commented 6 years ago

Any updates on this issue? I have the same problem i want the fonts.css to be minified when deploying to production