-
Notifications
You must be signed in to change notification settings - Fork 132
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move blockified code to the module instead
- Loading branch information
1 parent
eb0369c
commit d1bfb1b
Showing
11 changed files
with
99 additions
and
179 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,110 +1,106 @@ | ||
var MiniCssExtractPlugin = require('mini-css-extract-plugin'); | ||
var MiniCssExtractPlugin = require( 'mini-css-extract-plugin' ); | ||
var debug = process.env.NODE_ENV !== 'production'; | ||
var glob = require("glob"); | ||
var glob = require( 'glob' ); | ||
|
||
const entries = glob.sync("./blocks/src/**/block.js").reduce((acc, item) => { | ||
const name = item.replace( /blocks\/src\/(.*)\/block.js/, '$1' ) | ||
acc[ name ] = item; | ||
return acc; | ||
}, {}); | ||
const entries = glob.sync( './modules/**/lib/*-block.js' ).reduce( ( acc, item ) => { | ||
const name = item.replace( /modules\/(.*)\/lib\/(.*)-block.js/, '$1' ); | ||
acc[ name ] = item; | ||
return acc; | ||
}, {} ); | ||
|
||
// @todo | ||
var extractEditorSCSS = new MiniCssExtractPlugin({ | ||
filename: './[name].editor.build.css' | ||
}); | ||
var extractEditorSCSS = new MiniCssExtractPlugin( { | ||
filename: './[name].editor.build.css', | ||
} ); | ||
|
||
var extractBlockSCSS = new MiniCssExtractPlugin({ | ||
filename: './[name].style.build.css' | ||
}); | ||
var extractBlockSCSS = new MiniCssExtractPlugin( { | ||
filename: './[name].style.build.css', | ||
} ); | ||
|
||
var plugins = [extractEditorSCSS, extractBlockSCSS]; | ||
var plugins = [ extractEditorSCSS, extractBlockSCSS ]; | ||
|
||
var scssConfig = [ | ||
'css-loader', | ||
'sass-loader', | ||
]; | ||
var scssConfig = [ 'css-loader', 'sass-loader' ]; | ||
|
||
module.exports = [ | ||
{ | ||
context: __dirname, | ||
devtool: debug ? 'source-map' : null, | ||
mode: debug ? 'development' : 'production', | ||
// entry: './blocks/src/blocks.js', | ||
entry: entries, | ||
output: { | ||
path: __dirname + '/blocks/dist/', | ||
filename: "[name].build.js" | ||
}, | ||
externals: { | ||
'react': 'React', | ||
'react-dom': 'ReactDOM' | ||
}, | ||
module: { | ||
rules: [ | ||
{ | ||
test: /\.js$/, | ||
exclude: /node_modules/, | ||
use: [ | ||
{ | ||
loader: 'babel-loader' | ||
} | ||
] | ||
}, | ||
{ | ||
test: /editor\.scss$/, | ||
exclude: /node_modules/, | ||
// use: extractEditorSCSS.extract(scssConfig) | ||
use: [ MiniCssExtractPlugin.loader, ...scssConfig ], | ||
}, | ||
{ | ||
test: /style\.scss$/, | ||
exclude: /node_modules/, | ||
// use: extractBlockSCSS.extract(scssConfig) | ||
use: [ MiniCssExtractPlugin.loader, ...scssConfig ], | ||
} | ||
] | ||
}, | ||
plugins: plugins | ||
}, | ||
{ | ||
context: __dirname, | ||
devtool: debug ? 'source-map' : null, | ||
mode: debug ? 'development' : 'production', | ||
entry: { | ||
'calendar.react': __dirname + '/modules/calendar/lib/react/calendar.react.js', | ||
}, | ||
output: { | ||
path: __dirname + '/modules/calendar/lib/dist', | ||
filename: "[name].build.js" | ||
}, | ||
externals: { | ||
'react': 'React', | ||
'react-dom': 'ReactDOM', | ||
'moment': 'moment', | ||
'@wordpress/i18n': 'wp.i18n', | ||
'@wordpress/components': 'wp.components', | ||
'@wordpress/url': 'wp.url', | ||
'@wordpress/data': 'wp.data' | ||
}, | ||
module: { | ||
rules: [ | ||
{ | ||
test: /\.js$/, | ||
exclude: /node_modules/, | ||
use: [ | ||
{ | ||
loader: 'babel-loader' | ||
} | ||
] | ||
}, | ||
{ | ||
test: /style\.react\.scss$/, | ||
exclude: /node_modules/, | ||
// use: extractBlockSCSS.extract(scssConfig) | ||
use: [ MiniCssExtractPlugin.loader, ...scssConfig ], | ||
}, | ||
] | ||
}, | ||
plugins: plugins | ||
} | ||
{ | ||
context: __dirname, | ||
devtool: debug ? 'source-map' : null, | ||
mode: debug ? 'development' : 'production', | ||
entry: entries, | ||
output: { | ||
path: __dirname + '/dist/', | ||
filename: '[name].build.js', | ||
}, | ||
externals: { | ||
react: 'React', | ||
'react-dom': 'ReactDOM', | ||
}, | ||
module: { | ||
rules: [ | ||
{ | ||
test: /\.js$/, | ||
exclude: /node_modules/, | ||
use: [ | ||
{ | ||
loader: 'babel-loader', | ||
}, | ||
], | ||
}, | ||
{ | ||
test: /editor\.scss$/, | ||
exclude: /node_modules/, | ||
// use: extractEditorSCSS.extract(scssConfig) | ||
use: [ MiniCssExtractPlugin.loader, ...scssConfig ], | ||
}, | ||
{ | ||
test: /style\.scss$/, | ||
exclude: /node_modules/, | ||
// use: extractBlockSCSS.extract(scssConfig) | ||
use: [ MiniCssExtractPlugin.loader, ...scssConfig ], | ||
}, | ||
], | ||
}, | ||
plugins, | ||
}, | ||
{ | ||
context: __dirname, | ||
devtool: debug ? 'source-map' : null, | ||
mode: debug ? 'development' : 'production', | ||
entry: { | ||
'calendar.react': __dirname + '/modules/calendar/lib/react/calendar.react.js', | ||
}, | ||
output: { | ||
path: __dirname + '/modules/calendar/lib/dist', | ||
filename: '[name].build.js', | ||
}, | ||
externals: { | ||
react: 'React', | ||
'react-dom': 'ReactDOM', | ||
moment: 'moment', | ||
'@wordpress/i18n': 'wp.i18n', | ||
'@wordpress/components': 'wp.components', | ||
'@wordpress/url': 'wp.url', | ||
'@wordpress/data': 'wp.data', | ||
}, | ||
module: { | ||
rules: [ | ||
{ | ||
test: /\.js$/, | ||
exclude: /node_modules/, | ||
use: [ | ||
{ | ||
loader: 'babel-loader', | ||
}, | ||
], | ||
}, | ||
{ | ||
test: /style\.react\.scss$/, | ||
exclude: /node_modules/, | ||
// use: extractBlockSCSS.extract(scssConfig) | ||
use: [ MiniCssExtractPlugin.loader, ...scssConfig ], | ||
}, | ||
], | ||
}, | ||
plugins, | ||
}, | ||
]; |