forked from Automattic/Edit-Flow
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
74 lines (68 loc) · 1.52 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
var ExtractText = require('extract-text-webpack-plugin');
var debug = process.env.NODE_ENV !== 'production';
var glob = require("glob");
const entries = glob.sync("./blocks/src/**/block.js").reduce((acc, item) => {
const name = item.replace( /blocks\/src\/(.*)\/block.js/, '$1' )
acc[ name ] = item;
return acc;
}, {});
// @todo
var extractEditorSCSS = new ExtractText({
filename: './[name].editor.build.css'
});
var extractBlockSCSS = new ExtractText({
filename: './[name].style.build.css'
});
var plugins = [extractEditorSCSS, extractBlockSCSS];
var scssConfig = {
use: [
{
loader: 'css-loader'
},
{
loader: 'sass-loader',
options: {
outputStyle: 'compressed'
}
}
]
};
module.exports = {
context: __dirname,
devtool: debug ? 'sourcemap' : null,
mode: debug ? 'development' : 'production',
// entry: './blocks/src/blocks.js',
entry: entries,
output: {
path: __dirname + '/blocks/dist/',
filename: "[name].build.js"
},
externals: {
'react': "React",
"react-dom": "ReactDOM"
},
module: {
rules: [
{
test: /\.js$/,
exclude: /node_modules/,
use: [
{
loader: 'babel-loader'
}
]
},
{
test: /editor\.scss$/,
exclude: /node_modules/,
use: extractEditorSCSS.extract(scssConfig)
},
{
test: /style\.scss$/,
exclude: /node_modules/,
use: extractBlockSCSS.extract(scssConfig)
}
]
},
plugins: plugins
};