-
Notifications
You must be signed in to change notification settings - Fork 14
/
webpack.config.js
executable file
·144 lines (126 loc) · 4 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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
const webpack = require('webpack');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const CopyWebpackPlugin = require('copy-webpack-plugin');
const path = require('path');
const ExtractTextPlugin = require("extract-text-webpack-plugin");
const devMode = process.env.NODE_ENV === "development"
if (devMode) { console.log(">>> WEBPACK RUNNING IN DEV MODE <<<"); }
const extractSass = new ExtractTextPlugin({
filename: "../css/[name].bundle.css",
disable: false
});
// plugins
// const HtmlWebpackPluginConfig = new HtmlWebpackPlugin({
// hash: true,
// cache: false,
// template: __dirname + '/react-signup/app/index.html',
// filename: 'index.html',
// inject: 'body'
// });
const useDevHostname = process.env.LOCAL_DEV_HOSTNAME || "localhost"
const useDevPort = process.env.LOCAL_DEV_PORT || "52100"
// definePlugin takes raw strings and inserts them, so you can put strings of JS if you want.
const definePlugin = new webpack.DefinePlugin({
__DEV__: JSON.stringify(devMode),
'process.env.NODE_ENV': process.env.NODE_ENV ? JSON.stringify(process.env.NODE_ENV) : '"production"',
__DEV_HOSTNAME__: devMode ? `"http://${useDevHostname}:${useDevPort}"` : null,
__RECAPTCHA_SITE_KEY__: JSON.stringify(process.env.RECAPTCHA_SITE_KEY) || '"6LfIUrgZAAAAAKgk0qHACeb8jx_Fjz8Y5YW8Nqf7"',
});
const reactOutputPath = path.join(__dirname, "signup");
const CopyWebpackPluginConfig = new CopyWebpackPlugin([
{from: './react-signup/html', to: reactOutputPath},
{from: './react-signup/css', to: reactOutputPath + '/css'},
{from: './react-signup/img', to: reactOutputPath + '/img'}
]);
const localElmSrc = './elmSrc/';
const elmSource = __dirname + '/elmSrc/';
//const elmLoaders = devMode
// ? [{loader: 'elm-hot-loader'}, {loader: 'elm-webpack-loader'}]
// : [{loader: 'elm-webpack-loader'}];
// TODO - WEBPACK (or other) must handle building sass
const config = {
// context: path.join(__dirname, 'app'),
devServer: {
publicPath: '_site',
contentBase: path.join(__dirname, "_site"),
watchContentBase: true,
compress: true,
port: 9999,
inline: true,
hot: true,
host: '127.0.0.1',
},
externals: {
grecaptcha: {}
},
entry: {
reactSignup: ['./react-signup/app/index.js'],
//donationWidget: [localElmSrc + 'DonationWidget/index.js'],
//donationLog: [localElmSrc + 'DonationLog/index.js'],
mainCss: ['./_sass/main.scss'],
// memberUI: [localElmSrc + 'Flux/MemberUI/index.ts'],
// fluxScripts: [localElmSrc + 'Flux/MemberUI/scripts.ts'],
main: ['./src/web/main.js'],
common: ['./src/web/common.js'],
graphs: ['./src/web/graphs-ng.js'],
// donationGraphLogic: ['./src/web/donationGraphLogic.js'],
},
output: {
path: __dirname + "/js",
filename: "bundle-[name].js"
},
resolve: {
extensions: ['.ts', '.js', '.json']
},
module: {
rules: [
{
test: /\.js$/,
exclude: [/elm-stuff/, /node_modules/],
use: [{loader: "babel-loader",
query: {
presets:[ 'es2015', 'react', 'stage-2' ],
}}]
},
//{
// test: /\.elm$/,
// exclude: [/elm-stuff/, /node_modules/, /_site/],
// use: elmLoaders
//},
{
test: /\.tsx?$/,
exclude: [/_site/],
loader: 'ts-loader'
},
{
test: /\.scss$/,
use: extractSass.extract({
use: [
{
loader: "css-loader",
options: { url: false }
}, {
loader: "sass-loader",
options: {
includePaths: [__dirname + "/_sass", 'node_modules']
}
}],
// use style-loader in development
fallback: "style-loader"
})
},
]
},
plugins: [
// HtmlWebpackPluginConfig,
extractSass,
definePlugin,
CopyWebpackPluginConfig
],
// devtool: devMode ? 'eval-source-map' : false
};
if (devMode) { // dev build
config.plugins.push(new webpack.SourceMapDevToolPlugin({}))
} else { // production build
}
module.exports = config;