This repository has been archived by the owner on Dec 11, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathwebpack.config.babel.js
144 lines (127 loc) · 5.36 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
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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
import path from 'path';
import minimist from 'minimist';
import webpack from 'webpack';
import fs from 'fs';
let knownOptions = {
string: 'min',
default: {
'min': false
}
};
const options = minimist(process.argv.slice(2), knownOptions),
pkg = JSON.parse(fs.readFileSync('./package.json')),
currentYear = (new Date()).getFullYear();
let plugins = [
new webpack.DefinePlugin({
'ENVIRONMENT': JSON.stringify((process.env.NODE_ENV || 'development')),
'VERSION': JSON.stringify(require('./package.json').version),
'API': JSON.stringify(process.env.NODE_ENV == 'production' ? "https://rightfit.io/api" : (process.env.NODE_ENV == 'staging' ? "https://staging.rightfit.io/api" : "http://45.55.233.252:8080/api/v1"))
}), new webpack.optimize.CommonsChunkPlugin( /* chunkName= */ "vendor", /* filename= */ "vendor.js"), new webpack.optimize.DedupePlugin(), new webpack.ProvidePlugin({
// Automtically detect jQuery and $ as free var in modules
// and inject the jquery library
// This is required by many jquery plugins
jQuery: 'jquery-slim',
$: 'jquery-slim',
m: 'mithril',
Bullet: 'bullet',
Auth: 'modules/auth',
page: 'page',
restful: 'restful.js',
_: 'lodash'
//URI:'URI',
// graphed: "graphed",
// graphed: "graphed"
})
]
let webp_options = {
cache: true,
debug: true,
entry: {
app: ["bullet", "app"],
vendor: ["jquery-slim", "mithril"]
//bootstrap: ["!bootstrap-webpack!./app/bootstrap/bootstrap.config.js", "./app/bootstrap"],
//react: "./app/react"
},
output: {
path: path.join(__dirname, "public"),
publicPath: "./",
filename: "[name].bundle.min.js",
chunkFilename: "[id].bundle.min.js"
},
module: {
loaders: [{
test: /(\.jsx|\.js)$/, // Match both .js and .jsx
exclude: /node_modules/,
loader: 'babel-loader', // 'babel-loader' is also a valid name to reference
query: {
plugins: ['transform-runtime'],
presets: ['es2015', 'stage-0']
}
}
// required to write "require('./style.css')"
//{ test: /\.css$/, loader: "style-loader!css-loader" },
// required for bootstrap icons
//{ test: /\.woff$/, loader: "url-loader?prefix=font/&limit=5000&mimetype=application/font-woff" },
//{ test: /\.ttf$/, loader: "file-loader?prefix=font/" },
//{ test: /\.eot$/, loader: "file-loader?prefix=font/" },
//{ test: /\.svg$/, loader: "file-loader?prefix=font/" },
// required for react jsx
//, { test: /\.jsx$/, loader: "msx-loader" },
//,{ test: /\.jsx$/, loader: "msx-loader?insertPragma=React.DOM" },
]
},
resolve: {
alias: {
'app': path.join(__dirname, "client/app.js"),
'form': __dirname + '/less/definitions/behaviors/form.js',
'modules': __dirname + '/client/modules/',
'transition': __dirname + '/less/definitions/modules/transition.js',
'progress': __dirname + '/less/definitions/modules/progress.js',
'visibility': __dirname + '/less/definitions/behaviors/visibility.js',
'sidebar': __dirname + '/less/definitions/modules/sidebar.js',
'dropdown': __dirname + '/less/definitions/modules/dropdown.js',
'tab': __dirname + '/less/definitions/modules/tab.js',
'modal': __dirname + '/less/definitions/modules/modal.js',
'checkbox': __dirname + '/less/definitions/modules/checkbox.js',
'popup': __dirname + '/less/definitions/modules/popup.js',
'dimmer': __dirname + '/less/definitions/modules/dimmer.js',
'dropdown': __dirname + '/less/definitions/modules/dropdown.js',
'bullet': __dirname + '/plugins/bullet.js',
'lodash': __dirname + '/plugins/lodash.js',
'jquery-slim': __dirname + '/node_modules/jquery/dist/jquery.js',
'mithril': __dirname + '/plugins/mithril.js',
'mjsx_loader': __dirname + '/plugins/mjsx_loader.js',
'js': __dirname + '/plugins/',
'magnific': __dirname + '/plugins/jquery.magnific-popup.js',
'css': __dirname + '/plugins/css',
'datepicker': __dirname + '/plugins/datepicker'
// // Bind version of jquery
// jquery: "jquery-2.0.3",
// // Bind version of jquery-ui
// "jquery-ui": "jquery-ui-1.10.3",
// // jquery-ui doesn't contain a index file
// // bind module to the complete module
// "jquery-ui-1.10.3$": "jquery-ui-1.10.3/ui/jquery-ui.js",
}
},
plugins: plugins
};
if (options.min !== false) {
plugins.push((new webpack.optimize.UglifyJsPlugin({
output: {
comments: false
},
minimize: true
})))
}
//banner comment
plugins.push((new webpack.BannerPlugin([
pkg.name + " v" + pkg.version,
pkg.description,
pkg.homepage,
"Copyright (c) 2015-" + currentYear + " HATCH IT UP, Inc. All Rights Reserved.",
"Are you a frontend Ninja? work with us! email at " + pkg.career
].join("\n"), {
entryOnly: true
})))
module.exports = webp_options