Skip to content

Commit

Permalink
Add webpack config
Browse files Browse the repository at this point in the history
  • Loading branch information
ErikBernskiold committed Jul 26, 2021
1 parent 7c9c5ba commit 55e9d8e
Showing 1 changed file with 46 additions and 0 deletions.
46 changes: 46 additions & 0 deletions webpack.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
const path = require( 'path' );
const defaultConfig = require( '@wordpress/scripts/config/webpack.config' );
const fastGlob = require( 'fast-glob' );
const WebpackBar = require( 'webpackbar' );
const ReplaceInFileWebpackPlugin = require( 'replace-in-file-webpack-plugin' );

const sharedConfig = {
...defaultConfig,
plugins: [
...defaultConfig.plugins,
new ReplaceInFileWebpackPlugin( [
{
dir: 'dist',
test: [ /\.js/ ],
rules: [
{
search: /TEXTDOMAIN/gi,
replace: 'wp-plugin-scaffold',
},
],
},
] ),
],
};

const scripts = {
...sharedConfig,
entry: {
'app': './assets/scripts/src/index.js',
'admin': './assets/scripts/src/admin.js',
},
output: {
path: path.resolve( process.cwd(), 'dist' ),
filename: '[name].js',
chunkFilename: '[name].js',
},
plugins: [
...sharedConfig.plugins,
new WebpackBar( {
name: 'Scripts',
color: '#5aec1c',
} ),
],
};

module.exports = [ scripts ];

0 comments on commit 55e9d8e

Please sign in to comment.