forked from BenjaminLawson/PDF.js-Viewer-Shortcode
-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathwebpack.config.js
51 lines (50 loc) · 1.24 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
const MiniCssExtractPlugin = require( 'mini-css-extract-plugin' );
const debug = process.env.NODE_ENV !== 'production';
const WebpackShellPlugin = require('webpack-shell-plugin');
module.exports = {
context: __dirname,
devtool: debug ? 'inline-sourcemap' : null,
mode: debug ? 'development' : 'production',
entry: './blocks/src/blocks.js',
output: {
path: __dirname + '/blocks/dist/',
filename: 'blocks.build.js',
},
plugins: [
new MiniCssExtractPlugin( {
filename: 'style.css',
} ),
new WebpackShellPlugin( {
onBuildEnd: [ 'cp readme.md readme.txt' ],
} ),
],
module: {
rules: [
{
test: /\.js$/,
exclude: /node_modules/,
use: [
{
loader: 'babel-loader',
},
],
},
{
test: /editor\.scss$/,
exclude: /node_modules/,
// When loading editor styles we can just load them into the DOM
// directly with style-loader to avoid another bundle
use: [ 'style-loader', 'css-loader', 'sass-loader' ],
},
{
test: /style\.scss$/,
exclude: /node_modules/,
use: [
MiniCssExtractPlugin.loader, // 3) Extracts the CSS and bundles it
'css-loader', // 2) Truncates CSS into JS files
'sass-loader', // 1) Compiles SCSS -> CSS using node-sass
],
},
],
},
};