-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwebpack.config.js
More file actions
93 lines (86 loc) · 2.03 KB
/
Copy pathwebpack.config.js
File metadata and controls
93 lines (86 loc) · 2.03 KB
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
var path = require("path");
var BrowserSyncPlugin = require('browser-sync-webpack-plugin');
var proxy = require('http-proxy-middleware');
var sass = require("node-sass");
var shell = require("shelljs");
var Fs = require('fs');
function compileSCSS() {
sass.render({
file: "./scss/app.scss",
outFile: "./build/app.css",
sourceMap: true
}, function (err, result) {
if (err) {
return console.error(err);
}
Fs.writeFile("./build/app.css", result.css, function(err) {
});
});
}
var sidebarProxy = proxy('/sidebar', {
target: 'http://immown.dev',
changeOrigin: true,
});
var iconsProxy = proxy('/icons', {
target: 'http://immown.dev',
changeOrigin: true,
});
module.exports = {
entry: "./app/app.js",
devtool: "inline-source-map",
output: {
path: path.resolve(__dirname, "build"),
filename: "bundle.js"
},
resolve: {
extensions: ['', '.js', '.jsx', '.css'],
root: path.resolve(__dirname, "app")
},
module: {
loaders: [
{
test: /\.jsx?$/,
exclude: /node_modules/,
loader: 'babel',
query: {
presets: ['es2015', 'react', 'stage-2']
}
}
]
},
plugins: [
new BrowserSyncPlugin({
host: 'localhost',
port: 3000,
open: false,
server: { baseDir: ['build'] },
middleware: [iconsProxy, sidebarProxy],
files: [
"./build/app.css",
"./build/index.html",
"./build/img/**/*",
{
match: ["./scss/**/*.scss"],
fn: function(event, file) {
var index = file.indexOf(".scss");
if (index > 0 && index === file.length - 5) {
compileSCSS();
}
}
},
{
match: ["./img/**/*"],
fn: function(event, file) {
shell.cp("-R", "./img", "./build/img");
}
},
{
match: "./index.html",
fn: function(event, file) {
shell.cp("./index.html", "./build/index.html");
}
}
]
})
]
};