forked from new-tab-countdown/new-tab-countdown
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
130 lines (119 loc) · 3.18 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
127
128
129
130
var webpack = require("webpack"),
path = require("path"),
ExtractTextPlugin = require("extract-text-webpack-plugin"),
args = require("yargs").argv;
var path = require("path");
var IS_PROD = args.prod;
/* Transpile JSX files in this directory */
var JS_SOURCE_DIRS = [path.resolve(__dirname)];
/* Don't transpile files in this folder */
var JS_EXCLUDE_TRANSPILE_MATCH = /(node_modules)/;
/* Whether to create sourcemaps or not */
var JS_SOURCE_MAP = IS_PROD ? "source-map" : "source-map";
var CSS_SOURCE_DIRS = [path.join(__dirname, "src", "styles")];
var CSS_SOURCE_MAP = IS_PROD ? "!css!sass" : "!css?sourceMap!sass?sourceMap";
var CSS_OUTPUT_PATH = path.join("..", "styles", "site.css");
/* The files webpack uses to begin compilation */
var ENTRY_FILES = [
"babel-polyfill",
path.join(__dirname, "src", "components", "App.jsx"),
];
/* Describes the way Webpack should output files */
var OUTPUT_FILES = {
path: path.join(__dirname, "assets", "js"),
filename: "bundle.js",
};
var DEV_PLUGINS = [
new ExtractTextPlugin(CSS_OUTPUT_PATH),
new webpack.OldWatchingPlugin(),
];
var PROD_PLUGINS = [
new webpack.optimize.DedupePlugin(),
new webpack.optimize.AggressiveMergingPlugin(),
new webpack.optimize.UglifyJsPlugin({
sourceMap: true,
compress: {
sequences: false,
dead_code: false,
conditionals: false,
booleans: false,
unused: false,
if_return: false,
join_vars: false,
drop_console: false,
drop_debugger: false,
},
mangle: false,
output: {
comments: false,
},
}),
new ExtractTextPlugin(CSS_OUTPUT_PATH),
new webpack.OldWatchingPlugin(),
];
module.exports = [
{
name: "bundle",
entry: ENTRY_FILES,
output: OUTPUT_FILES,
target: "web",
devtool: JS_SOURCE_MAP,
resolve: {
extensions: ["", ".js", ".jsx"],
},
module: {
loaders: [
{
/* Babel Loader: Transpiles ES6 -> ES5 */
test: /\.jsx?$/,
include: [JS_SOURCE_DIRS],
exclude: JS_EXCLUDE_TRANSPILE_MATCH,
loader: "babel-loader",
query: {
presets: ["react", "es2015", "stage-0"],
plugins: [
"babel-plugin-transform-decorators-legacy",
"transform-runtime",
],
cacheDirectory: true,
},
},
{
/* SCSS Loader: Transpiles .SCSS -> .CSS*/
test: /\.scss$/,
loader: ExtractTextPlugin.extract("style", CSS_SOURCE_MAP),
},
],
},
sassLoader: {
includePaths: [CSS_SOURCE_DIRS],
},
debug: !IS_PROD,
plugins: IS_PROD
? PROD_PLUGINS.concat([
new webpack.DefinePlugin({
"process.env.NODE_ENV": JSON.stringify("production"),
}),
])
: DEV_PLUGINS,
},
];
Date.now = function () {
var now = new Date();
var hours = now.getHours();
var indicator = hours >= 12 ? "PM" : "AM";
hours = hours % 12;
hours = hours ? hours : 12;
return (
(hours < 10 ? "0" : "") +
hours +
":" +
(now.getMinutes() < 10 ? "0" : "") +
now.getMinutes() +
":" +
(now.getSeconds() < 10 ? "0" : "") +
now.getSeconds() +
" " +
indicator
);
};