Skip to content

Instantly share code, notes, and snippets.

@JMWebDevelopment
Created April 20, 2018 21:50
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JMWebDevelopment/7f86acdc5f920312662ebb50a0b13de1 to your computer and use it in GitHub Desktop.
Save JMWebDevelopment/7f86acdc5f920312662ebb50a0b13de1 to your computer and use it in GitHub Desktop.
const path = require( 'path' );
const webpack = require( 'webpack' );
const ExtractTextPlugin = require( 'extract-text-webpack-plugin' );
// const BrowserSyncPlugin = require( 'browser-sync-webpack-plugin' );
// Set different CSS extraction for editor only and common block styles
const blocksCSSPlugin = new ExtractTextPlugin( {
filename: './blocks/css/blocks.style.css',
} );
const editBlocksCSSPlugin = new ExtractTextPlugin( {
filename: './blocks/css/blocks.editor.css',
} );
// Configuration for the ExtractTextPlugin.
const extractConfig = {
use: [
{ loader: 'raw-loader' },
{
loader: 'postcss-loader',
options: {
plugins: [ require( 'autoprefixer' ) ],
},
},
{
loader: 'sass-loader',
query: {
outputStyle:
'production' === process.env.NODE_ENV ? 'compressed' : 'nested',
},
},
],
};
module.exports = {
entry: {
'./blocks/js/editor.blocks' : './blocks/index.js',
// './assets/js/frontend.blocks' : './blocks/frontend.js',
},
output: {
path: path.resolve( __dirname ),
filename: '[name].js',
},
watch: true,
devtool: 'cheap-eval-source-map',
module: {
rules: [
{
test: /\.js$/,
exclude: /(node_modules|bower_components)/,
use: {
loader: 'babel-loader',
},
},
/*{
test: /style\.s?css$/,
use: blocksCSSPlugin.extract( extractConfig ),
},*/
{
test: /editor\.s?css$/,
use: editBlocksCSSPlugin.extract( extractConfig ),
},
],
},
plugins: [
blocksCSSPlugin,
editBlocksCSSPlugin,
// new BrowserSyncPlugin({
// // Load localhost:3333 to view proxied site
// host: 'localhost',
// port: '3333',
// // Change proxy to your local WordPress URL
// proxy: 'https://gutenberg.local'
// })
],
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment