generated from DLXPlugins/highlight-and-share
-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
113 lines (111 loc) · 2.85 KB
/
webpack.config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
const defaultConfig = require( '@wordpress/scripts/config/webpack.config' );
const MiniCssExtractPlugin = require( 'mini-css-extract-plugin' );
const RemoveEmptyScriptsPlugin = require( 'webpack-remove-empty-scripts' );
const path = require( 'path' );
module.exports = ( env ) => {
return [
{
...defaultConfig,
module: {
...defaultConfig.module,
rules: [ ...defaultConfig.module.rules ],
},
mode: env.mode,
devtool: 'source-map',
},
{
entry: {
'insta-admin-landing-page': [ './src/scss/admin-landing.scss' ],
'insta-admin-block-editor': [ './src/scss/admin-block-editor.scss' ],
},
mode: env.mode,
devtool: 'production' === env.mode ? false : 'source-map',
output: {
filename: '[name].js',
sourceMapFilename: '[file].map[query]',
assetModuleFilename: 'fonts/[name][ext]',
clean: true,
},
resolve: {
alias: {
react: path.resolve( 'node_modules/react' ),
'react-dom': path.resolve( 'node_modules/react-dom' ),
'@wordpress/i18n': path.resolve( 'node_modules/@wordpress/i18n' ),
'@wordpress/element': path.resolve( 'node_modules/@wordpress/element' ),
'@wordpress/components': path.resolve( 'node_modules/@wordpress/components' ),
'@wordpress/block-editor': path.resolve( 'node_modules/@wordpress/block-editor' ),
'@wordpress/hooks': path.resolve( 'node_modules/@wordpress/hooks' ),
},
},
module: {
rules: [
{
test: /\.(js|jsx)$/,
exclude: /(node_modules|bower_components)/,
loader: 'babel-loader',
options: {
presets: [ '@babel/preset-env', '@babel/preset-react' ],
plugins: [
'@babel/plugin-proposal-class-properties',
'@babel/plugin-transform-arrow-functions',
'lodash',
],
},
},
{
test: /\.scss$/,
exclude: /(node_modules|bower_components)/,
use: [
{
loader: MiniCssExtractPlugin.loader,
},
{
loader: 'css-loader',
options: {
sourceMap: true,
},
},
{
loader: 'resolve-url-loader',
},
{
loader: 'sass-loader',
options: {
sourceMap: true,
},
},
],
},
{
test: /\.css$/,
include: [
path.resolve(
__dirname,
'node_modules/@wordpress/components/build-style/style.css'
),
],
use: [
{
loader: MiniCssExtractPlugin.loader,
},
{
loader: 'css-loader',
options: {
sourceMap: true,
},
},
'sass-loader',
],
},
{
test: /\.(woff2?|ttf|otf|eot|svg)$/,
include: [ path.resolve( __dirname, 'fonts' ) ],
exclude: /(node_modules|bower_components)/,
type: 'asset/resource',
},
],
},
plugins: [ new RemoveEmptyScriptsPlugin(), new MiniCssExtractPlugin() ],
},
];
};