Hi I am new to Magento 2, I was wondering what methods people are using to keep CSS changes after they deploy static content as CSS changes are overwritten every time.
Thanks!
Hi I am new to Magento 2, I was wondering what methods people are using to keep CSS changes after they deploy static content as CSS changes are overwritten every time.
Thanks!
Never work in cache css files in pub/static folder. Files under this folder always overwritten when deploy command is run.
Option: Installing and configuring Grunt
Magento has built-in Grunt tasks configured, but there are still several prerequisite steps you need to take to be able to use it:
Install node.js to any location on your machine. Install Grunt CLI tool globally. To do this, run the following command in a command prompt:
npm install -g grunt-cli
Install (or refresh) the node.js project dependency, including Grunt, for your Magento instance. To do this, run the following commands in a command prompt: cd npm install
Add your theme to Grunt configuration. To do this, in the dev/tools/grunt/configs/themes.js file, add your theme to module.exports like following:
module.exports = {
<theme>: {
area: 'frontend',
name: '<Vendor>/<theme>',
locale: '<language>',
files: [
'<path_to_file1>', //path to root source file
'<path_to_file2>'
],
dsl: 'less'
...
},
After configure run following commands:
grunt clean: eg: customtheme is name of my theme
Republishes symlinks to the source files to the pub/static/frontend/// directory.
grunt exec:
Compiles .css files using the symlinks published in the pub/static/frontend/// directory
grunt less:
Tracks the changes in the source files, recompiles .css files, and reloads the page in the browser pages
grunt watch