| 1 |
const defaultConfig = require( '@wordpress/scripts/config/webpack.config' ); |
| 2 |
const path = require( 'path' ); |
| 3 |
|
| 4 |
const wp_rules = defaultConfig.module.rules.filter( function ( item ) { |
| 5 |
if ( String( item.test ) === String( /\.jsx?$/ ) ) { |
| 6 |
return true; |
| 7 |
} |
| 8 |
|
| 9 |
if ( String( item.test ) === String( /\.(sc|sa)ss$/ ) ) { |
| 10 |
item.exclude = [ /node_modules/, /editor/ ]; |
| 11 |
return true; |
| 12 |
} |
| 13 |
return false; |
| 14 |
} ); |
| 15 |
|
| 16 |
module.exports = { |
| 17 |
...defaultConfig, |
| 18 |
entry: { |
| 19 |
blocks: path.resolve( __dirname, 'src/blocks.js' ), |
| 20 |
}, |
| 21 |
|
| 22 |
resolve: { |
| 23 |
alias: { |
| 24 |
...defaultConfig.resolve.alias, |
| 25 |
'@Controls': path.resolve( __dirname, 'src/controls/' ), |
| 26 |
'@Components': path.resolve( __dirname, 'src/components/' ), |
| 27 |
'@CFBlocks': path.resolve( __dirname, 'src/blocks/' ), |
| 28 |
'@Utils': path.resolve( __dirname, 'src/utils/' ), |
| 29 |
'@Attributes': path.resolve( __dirname, 'src/blocks-attributes/' ), |
| 30 |
}, |
| 31 |
}, |
| 32 |
module: { |
| 33 |
rules: [ |
| 34 |
...wp_rules, |
| 35 |
{ |
| 36 |
test: /\.(scss|css)$/, |
| 37 |
exclude: [ /node_modules/, /style/ ], |
| 38 |
use: [ |
| 39 |
{ |
| 40 |
loader: 'style-loader', |
| 41 |
options: { |
| 42 |
injectType: 'lazySingletonStyleTag', |
| 43 |
attributes: { id: 'uagb-editor-styles' }, |
| 44 |
}, |
| 45 |
}, |
| 46 |
'css-loader', |
| 47 |
'sass-loader', |
| 48 |
], |
| 49 |
}, |
| 50 |
], |
| 51 |
}, |
| 52 |
// output: { |
| 53 |
// ...defaultConfig.output, |
| 54 |
// // eslint-disable-next-line no-undef |
| 55 |
// path: path.resolve( __dirname, 'build' ), |
| 56 |
// }, |
| 57 |
}; |
| 58 |
|