This repository has been archived by the owner on Jun 14, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 57
/
webpack.config.js
80 lines (74 loc) · 1.6 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
const ExtractText = require( 'extract-text-webpack-plugin' );
const path = require('path');
const devMode = process.env.NODE_ENV !== 'production';
const editorStyles = new ExtractText( {
filename: './blocks.editor.build.css',
} );
const frontendStyles = new ExtractText( {
filename: './blocks.style.build.css',
} );
const plugins = [ editorStyles, frontendStyles ];
const scssConfig = {
use: [
{
loader: 'css-loader',
},
{
loader: 'sass-loader',
options: {
prependData: '@import "./src/common.scss";\n',
},
},
],
};
module.exports = {
context: __dirname,
devtool: devMode ? 'inline-sourcemap' : false,
mode: devMode ? 'development' : 'production',
entry: {
blocks: './src/blocks.js',
},
output: {
path: __dirname + '/dist/',
filename: '[name].build.js',
},
module: {
rules: [
{
test: /\.js$/,
exclude: [
path.resolve( __dirname, 'node_modules' ),
path.resolve( __dirname, 'build' ),
path.resolve( __dirname, 'vendor' ),
],
use: [
{
loader: 'babel-loader',
options: {
presets: [ '@babel/preset-react' ],
},
},
],
},
{
test: /editor\.scss$/,
exclude: [
path.resolve( __dirname, 'node_modules' ),
path.resolve( __dirname, 'build' ),
path.resolve( __dirname, 'vendor' ),
],
use: editorStyles.extract( scssConfig ),
},
{
test: /style\.scss$/,
exclude: [
path.resolve( __dirname, 'node_modules' ),
path.resolve( __dirname, 'build' ),
path.resolve( __dirname, 'vendor' ),
],
use: frontendStyles.extract( scssConfig ),
},
],
},
plugins,
};