Guide on implementing postcss (lost grid) with vue-loader

Exploring the potential of Vue2, I find myself facing a dilemma with incorporating lost-grid () into my application. Having successfully utilized this postcss grid-system in react apps with webpack2 multiple times, I am now unsure how to implement it with vue-loader.

Despite installing 'lost' via npm and attempting various approaches to include the postcss loader, none of my efforts have yielded results so far. The documentation has not proven very helpful either.

The crucial section of webpack.base.conf.js is as follows (where it seems that all CSS loading is handled by the vue-loader):

module: {
    rules: [
      {
        test: /\.(js|vue)$/,
        loader: 'eslint-loader',
        enforce: "pre",
        include: [resolve('src'), resolve('test')],
        options: {
          formatter: require('eslint-friendly-formatter')
        }
      },
      {
        test: /\.vue$/,
        loader: 'vue-loader',
        options: vueLoaderConfig
      },
      {

...

Looking at vue-loader.conf.js:

var utils = require('./utils')
var config = require('../config')
var isProduction = process.env.NODE_ENV === 'production'

module.exports = {
  loaders: utils.cssLoaders({
    sourceMap: isProduction
      ? config.build.productionSourceMap
      : config.dev.cssSourceMap,
    extract: isProduction
  })
}

Here is a glimpse into utils.js:

var path = require('path')
var config = require('../config')
var ExtractTextPlugin = require('extract-text-webpack-plugin')

exports.assetsPath = function (_path) {
  var assetsSubDirectory = process.env.NODE_ENV === 'production'
    ? config.build.assetsSubDirectory
    : config.dev.assetsSubDirectory
  return path.posix.join(assetsSubDirectory, _path)
}

...

As I navigate through these files, a question arises – where should each piece fit in? Any guidance on this matter would be immensely appreciated.

Answer №1

To incorporate the following code snippet into the vue-loader.config.js file located in the build directory:

postcss: [
    require('autoprefixer')({
        browsers: ['last 7 versions']
    })
]

Your updated vue-loader.config.js should now resemble this:

 module.exports = {
  loaders: utils.cssLoaders({
    sourceMap: isProduction ? config.build.productionSourceMap : config.dev.cssSourceMap,
    extract: isProduction
  }),
  postcss: [
    require('autoprefixer')({
      browsers: ['last 7 versions']
    })
  ]
}

Answer №2

The 'lost' module needs to be included in the postcss Array as shown above

Answer №3

"browserslist": [ "> 1%", "last 2 versions", "not ie <= 8" ]

The package.json file contains the defined browserslist configuration, which can be viewed at this link

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

JavaScript manipulates CakePHP forms

Is it possible to dynamically generate form fields using PHP? <?php echo $this->Form->input('Model.0.name', array( 'label' => __('Name') ) ); ?> I am looking for a way to create fie ...

How Webpack 4 Utilizes splitChunks to Create Numerous CSS Files

I need to create multiple CSS files using webpack 4 with the min-css-extract-plugin and splitChunks plugin. Here is my webpack configuration. const MiniCssExtractPlugin = require("mini-css-extract-plugin"); const path = require("path"); module.exports = ...

I'm experiencing difficulties with the "AXIOS PATCH" functionality

I am attempting to modify a database record using the "axios patch" method. This is the code I have tried: editClient(client) { let data = new FormData(); data.append("name", this.client.name); data.append("email", this.client.email); data.append ...

What is the process of exporting and importing in TypeScript?

As I was diving into the Angular2 quickstart tutorial with both Javascript and Typescript, I noticed a difference in how components and modules are handled. In the Javascript version, they are first assigned to a variable (specifically window.app), which ...

Refreshing the DOM following an API call using VueJS

Struggling with updating the DOM after fetching data from an API. Although my object is successfully fetching the data, the DOM renders before receiving the API Data and fails to update afterward. I'm puzzled as to why it's not refreshing itself ...

Using Underscore.js debouncer for onresize events - managing .on() and .off() alongside Window Widths [Enquire.js]

In the following code snippet, vw (viewport width) font sizing is simulated only when the window width exceeds 375px. When the window width drops below 375px, jQuery disables resize.mymethod. /* This plugin mimics vw (viewport width) */ function Suppo ...

Retrieve the content of a text field with jQuery

Check out this block of HTML: <div class="sub-middle-column"> <div class="div-header">Grandsire <a "#", class="table-control-focus sub-header-table-focus" id="table-control-focus-t" >abc</a> <ul class="table-controls h ...

What is the best way to choose "this" element in Angular?

Within my template, I have 5 buttons each utilizing the same ng-click function. These buttons essentially function as a tabbed navigation system, where clicking on one button directs the user to that specific tab's content pane. All of these buttons c ...

How to transform a JSON object into an array using JavaScript

Is there a way to convert a JSON key value object into an Array that is easier to iterate through? The JSON I have looks something like this: { "01": "yes", "02": "yes", "03": "no" } However, I need the Array format below in order to easily iterate ...

The network activity displays the Header() redirect, but the actual redirection is not taking place

I have been working on a process that involves checking for a specific cookie when a user lands on the home page. If the cookie is not found, the user gets redirected to login.php. To authenticate the user, I make a POST request to a third-party API using ...

Aggregation pipeline update or push in MongoDB

I have a database model in MongoDB that includes an array of members as objects. const guestSchema = new mongoose.Schema({ salutation: { type: String, }, members: [membersSchema], user: { type: mongoose.Schema.ObjectId, ref: 'User& ...

Numerous titles being showcased

I need to enhance the functionality of clicking on multiple objects in order to display all titles at once within the header. Currently, only one title is shown each time an object is clicked. Therefore, when clicking on items 1, 2, and 3, I expect to se ...

Placing Google Adsense among the content created using a JQuery loop

I have implemented a search function on my website that retrieves results from the database in JSON format. These results are then dynamically displayed by appending a DIV or SPAN element within a loop. $("#btnGetresult" ).click(function(e) { var ...

Choose an option from the selection menu automatically using a link

I am looking to utilize either PHP or JavaScript in order to link to a page and add either "?type=foo" or "#foo" at the end of the URL. This will allow for a specific option to be automatically selected from a dropdown menu within a form when the linked ...

techniques for presenting tabular data in a JavaScript modal

Hey there! I'm looking for a way to show table formatted data in a JavaScript popup. Do you know if it's possible to display table formatted data in a JavaScript popup using ASP.NET and C#? ...

I require assistance in understanding how to successfully implement ParseINT with (row.find)

enter image description hereHow To Utilize ParseINT Using row.find(). I Attempted This Code But It Doesn't Work. This is My Code : function update_qty() { var row2 = $(this).parents('.item-row'); var price2 = row2.find(parseInt($ ...

Utilizing service-based global objects in Angular applications

Upon entry into my application, the GlobalApplicationController initializes several services that are utilized throughout the entire application, such as subscribing to sockets. It would be quite beneficial to have a CurrentUser object available - however, ...

Ensure the video frame stretches to fit the full width

I am struggling to make my video frame fill the entire width of the screen. Even though I have tried using CSS, the video container does not stretch to the full width as expected. https://i.sstatic.net/kxyE0.png How can I ensure that the video plays acro ...

Tips for showcasing several images with accompanying content once the webpage has finished loading

I am faced with an issue on my PHP website. The website is a social networking platform with numerous images and contents. I am seeking a way to first display only the content to the user, then show the images after they have all finished loading. Addition ...

The Webpack bundling process creates a library that is distinguishable from the original library found in a Node

There is a particular file I'm working with: // in.js var util = require('util') console.log(typeof util.inspect.defaultOptions) When executed with Node.js, everything runs smoothly: C:\Users\artur\tmp>node in.js object ...