Skip to content

Commit

Permalink
Generate css file in build folder using Webpack
Browse files Browse the repository at this point in the history
@Shelob9 This generates the build version of index.scss, the clients/admin/build/style.min.css still needs to be enqueued and I'm not sure if we want to enqueue css files from the clients folder or move theme and enqueue from the assets folder.
BTW, the admin client is loading these styles via import within the index.js file, once we decide where we enqueue css from we can remove the import.
  • Loading branch information
New0 committed Oct 24, 2018
1 parent 317e735 commit b615414
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,8 @@ const ExtractTextPlugin = require( 'extract-text-webpack-plugin' );
//Creates HTML for mounting using a PHP file
const HtmlWebpackPlugin = require('html-webpack-plugin');


// Main CSS loader for everything but blocks..
const cssExtractTextPlugin = new ExtractTextPlugin({
// Extracts CSS into a build folder inside the directory current directory
filename: './build/[name]/build/style.min.css'
});
// Main CSS loader
let cssExtractTextPlugin;

// Configuration for the ExtractTextPlugin.
// Handles CSS
Expand Down Expand Up @@ -57,6 +53,14 @@ entryPointNames.forEach( entryPointName => {
externals[ '@/calderaForms' + entryPointName ] = {
this: [ 'calderaForms', entryPointName ]
}

// CSS loader for Admin client ( condition defines which client is using CSS loader )
if( entryPointName === 'admin' ){

This comment has been minimized.

Copy link
@Shelob9

Shelob9 Oct 24, 2018

Collaborator

@New0 Am I understanding correctly that if I wanted to add CSS loading for another client, I could change this line to if( entryPointName === 'admin' || entryPointName === 'blocks' ){ ?

cssExtractTextPlugin = new ExtractTextPlugin({
// Extracts CSS into a build folder inside the current directory
filename: './clients/' + entryPointName + '/build/style.min.css'
});
}
} );

// Define WordPress dependencies
Expand Down

2 comments on commit b615414

@Shelob9
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Shelob9
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@New0 I will create a real solution to this via #2789

An acceptable quick fix for you:
Look in caldera-core.php around line 195, I'm hooking caldera_forms_admin_assets_styles_registered to load old CSS. Change the file file path passed to wp_enqueue_style or add another enqueue.

Please sign in to comment.