-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.babel.js
105 lines (94 loc) · 3.04 KB
/
webpack.config.babel.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
/* global process, __dirname */
import path from "path";
import webpack from "webpack";
import merge from "webpack-merge";
const TARGET = process.env.npm_lifecycle_event;
const ROOT_PATH = path.resolve(__dirname);
const srcDir = path.join(__dirname, "src");
// const bowerDir = ROOT_PATH + "/bower_components";
const PATHS = {
src: "src/",
srcjs: "src/js"
};
// console.log("webpack is using webpack.config.babel.js, TARGET = " + TARGET);
var exportModule = {};
const common = {
entry: {
index: path.resolve(ROOT_PATH) + "/" + PATHS.srcjs + "/index.js"
},
resolve: {
// Hard-coded path to kendo src files is only necessary due to this
// bug: https://github.com/webpack/webpack/issues/1897
// Note: this wasn"t require in previous releases of kendo
modulesDirectories: ["node_modules", "bower_components",
path.join(__dirname, "bower_components/kendo-ui/src/js")
]
},
module: {
loaders: [{
loader: "babel-loader",
include: [
path.resolve(__dirname, PATHS.srcjs)
],
// Only run `.js` files through Babel
test: /\.js?$/
}]
},
plugins: [
// Doesn't work with the 2016 versions of Kendo. I don"t know why. It worked
// with the 2015 versions. So have added a separate <script> tag to load
// jQuery for now.
// new webpack.ProvidePlugin({
// $: "jquery",
// jQuery: "jquery",
// "window.jQuery": "jquery"
// })
],
devtool: "source-map"
};
if (TARGET === "buildwp") {
console.log("running buildwp");
// Includes minification, so slow build times and smaller files. Use for final build to prod only.
exportModule = merge(common, {
output: {
path: path.resolve(ROOT_PATH, "build/js/"),
filename: "[name].js"
},
plugins: [
new webpack.optimize.CommonsChunkPlugin("vendor", "vendor.js", function(module) {
return module.resource && module.resource.indexOf(srcDir) === -1;
}),
new webpack.optimize.UglifyJsPlugin({
compress: {
warnings: false
}
}),
new webpack.optimize.DedupePlugin()
]
});
}
// Note when inline is set to true, we get an error:
// Module not found: Error: Cannot resolve "file" or "directory" ./dist/debug.js
// see http://stackoverflow.com/questions/34549508/webpack-dev-server-error-with-hot-module-replacement
const devServerCommon = {
devServer: {
colors: true,
noInfo: false,
historyApiFallback: true,
hot: true,
inline: true,
progress: true
},
plugins: [
new webpack.HotModuleReplacementPlugin()
]
};
const startCommon = merge(common, devServerCommon);
if (TARGET === "start" || !TARGET) {
exportModule = merge(startCommon, {
output: {
filename: "src/[name]bundle.js"
}
});
}
export default exportModule;