-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
64 lines (58 loc) · 1.61 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
import ExtractTextPlugin from 'extract-text-webpack-plugin';
import { DefinePlugin } from 'webpack';
// postcssLoader exports the webpack config for all styles
const postcssLoader = env => {
const loader = {
// Local development server
dev: [
{ loader: 'style-loader' },
{ loader: 'css-loader', options: { importLoaders: 1 } },
{ loader: 'postcss-loader' }
],
// Production build
prod: ExtractTextPlugin.extract({
use: [
{
loader: 'css-loader',
options: {
importLoaders: 1,
minimize: true,
sourceMap: false
}
},
{ loader: 'postcss-loader' }
]
})
};
return {
test: /\.css$/,
use: env !== 'node' ? loader[env] : loader.prod
};
};
export default (config, { defaultLoaders, stage }) => {
if (stage === 'prod') {
config.entry = ['babel-polyfill', config.entry];
} else if (stage === 'dev') {
config.entry = ['babel-polyfill', ...config.entry];
}
config.plugins.push(
new DefinePlugin({
LAMBDA_ENDPOINT: JSON.stringify(process.env.LAMBDA_ENDPOINT),
SITE_BASE_URL: JSON.stringify(process.env.SITE_BASE_URL),
SITE_SEARCH_TOKEN: JSON.stringify(process.env.SITE_SEARCH_TOKEN),
STRIPE_API_KEY: JSON.stringify(process.env.STRIPE_API_KEY),
STRIPE_PUBLISHABLE_KEY: JSON.stringify(process.env.STRIPE_PUBLISHABLE_KEY)
})
);
config.module.rules = [
{
oneOf: [
postcssLoader(stage),
defaultLoaders.cssLoader,
defaultLoaders.jsLoader,
defaultLoaders.fileLoader
]
}
];
return config;
};