-
Notifications
You must be signed in to change notification settings - Fork 3
/
webpack.config.js
126 lines (125 loc) · 3.47 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
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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
/* eslint-env node */
const path = require("path");
const webpack = require("webpack");
const ExtractTextPlugin = require("extract-text-webpack-plugin");
const StringReplacePlugin = require("string-replace-webpack-plugin");
const extractStyles = new ExtractTextPlugin("main.css");
const HtmlWebpackPlugin = require("html-webpack-plugin");
const externalAssets = require("./lib/javascripts/external_assets");
module.exports = function (env) {
return {
entry: {
app: [
"babel-polyfill",
"./src/javascripts/index.js",
"./src/stylesheets/app.scss"
]
},
output: {
path: path.resolve(__dirname, "./dist/assets"),
filename: "main.js",
sourceMapFilename: "[file].map"
},
module: {
rules: [
{
test: /\.js$/,
exclude: /node_modules/,
enforce: "pre",
loader: "eslint-loader"
},
{
test: /\.(gif|jpe?g|png|svg|woff2?|ttf|eot)$/,
loader: "url-loader?limit=10000&name=[name].[ext]"
},
{
test: /\.scss$/,
use: extractStyles.extract({
fallback: "style-loader",
use: [
"css-loader?sourceMap&root=" +
path.resolve(__dirname, "./dist/assets"),
"sass-loader?sourceMap"
]
})
},
{
test: /\.json$/,
include: path.resolve(__dirname, "./src/translations"),
loader: "translations-loader",
options: {
runtime: "handlebars"
}
},
{
test: /index\.js$/,
exclude: /node_modules/,
loader: StringReplacePlugin.replace({
replacements: [
{
pattern: '// SENTRY_INTEGRATION',
replacement: function (match, p, offset, string) {
try {
return 'Sentry.init({dsn: "' + env.SENTRY_DSN + '"});';
} catch (err) {
return '';
}
}
}
]
})
},
{
test: /\.js$/,
exclude: /node_modules/,
loader: "babel-loader",
options: {
"sourceMaps": true,
}
},
{
test: /\.(handlebars|hd?bs)$/,
loader: "handlebars-loader",
options: {
extensions: [".handlebars", ".hdbs", ".hbs"],
runtime: "handlebars",
inlineRequires: "/images/"
}
}
]
},
resolveLoader: {
modules: ["node_modules", path.resolve(__dirname, "./lib/loaders")]
},
resolve: {
modules: ["node_modules", path.resolve(__dirname, "./lib/javascripts")],
alias: {
app_manifest: path.resolve(__dirname, "./dist/manifest.json")
}
},
externals: {
handlebars: "Handlebars",
jquery: "jQuery",
lodash: "_",
moment: "moment",
zendesk_app_framework_sdk: "ZAFClient"
},
devtool: "#eval",
plugins: [
extractStyles,
new HtmlWebpackPlugin({
warning:
"AUTOMATICALLY GENERATED FROM ./lib/templates/layout.hdbs - DO NOT MODIFY THIS FILE DIRECTLY",
vendorCss: externalAssets.css,
vendorJs: externalAssets.js,
template: "!!handlebars-loader!./lib/templates/layout.hdbs"
}),
new webpack.optimize.UglifyJsPlugin({
compress: {
drop_debugger: false,
warnings: false
}
})
]
};
}