Thursday, March 1, 2018

Using JSON with Laravel Mix Postcss Uncss plugin - development

Using JSON with Laravel Mix Postcss Uncss plugin

I’m trying to feed json data from a URL to a postcss-uncss, as the list of pages that postcss-uncss should analyze but I cant seem to get it to see the data. It complains that pageList is undefined. How can I do this?

const request = require("request")
var url = "http://domain.dev/uncss.json";
request(url, function (error, response, body) {
  if (!error && response.statusCode == 200) {
    let pageList = JSON.parse(body);
  }
})
mix.options({
  postCss: [
    require('autoprefixer')(),
    // This is not a laravel project, so we cant use PurifyCSS...
    require('postcss-uncss')({
      html: pageList,
      ignore: [/.(uniform|form-error-hint|error|valid|required)/]
    }),
  ],
})



from Laravel Questions and Answers https://laravelquestions.com/laravel/using-json-with-laravel-mix-postcss-uncss-plugin/
via Lzo Media

No comments:

Post a Comment