-
Notifications
You must be signed in to change notification settings - Fork 18
Expand file tree
/
Copy pathwebpack.dev.config.js
More file actions
66 lines (63 loc) · 1.92 KB
/
webpack.dev.config.js
File metadata and controls
66 lines (63 loc) · 1.92 KB
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
import path from 'path'
import webpack from 'webpack'
import autoprefixer from 'autoprefixer'
import postcssApply from 'postcss-apply'
import postcssCalc from 'postcss-calc'
import postcssColorFunction from 'postcss-color-function'
import postcssCustomMedia from 'postcss-custom-media'
import postcssCustomProperties from 'postcss-custom-properties'
import postcssImport from 'postcss-import'
import postcssPxToRem from 'postcss-pxtorem'
import postcssReporter from 'postcss-reporter'
import postcssUrl from 'postcss-url'
import pkg from './package.json'
// load env vars first
require('dotenv').load({ silent: process.env.NODE_ENV === 'production' })
module.exports = {
devtool: 'source-map',
entry: {
main: ['./src/main', 'webpack-hot-middleware/client'],
},
output: {
filename: '[name].entry.js',
path: path.join(__dirname, 'public/static'),
publicPath: '/static/',
},
plugins: [
new webpack.HotModuleReplacementPlugin(),
new webpack.NoErrorsPlugin(),
new webpack.DefinePlugin({
__DEV__: JSON.stringify(JSON.parse(process.env.BUILD_DEV || 'true')),
__PRERELEASE__: JSON.stringify(JSON.parse(process.env.BUILD_PRERELEASE || 'false')),
ENV: JSON.stringify(require(path.join(__dirname, './env.js'))), // eslint-disable-line
}),
],
module: {
loaders: [
{
test: /\.js$/,
loader: 'babel',
include: path.join(__dirname, 'src'),
exclude: /node_modules/,
},
{
test: /\.css$/,
loaders: ['style-loader', 'css-loader', 'postcss-loader'],
},
],
},
postcss(wp) {
return [
postcssImport({ addDependencyTo: wp }),
postcssUrl(),
postcssCustomProperties(),
postcssApply(),
postcssCalc(),
postcssColorFunction(),
postcssCustomMedia(),
postcssPxToRem({ propWhiteList: [], minPixelValue: 5 }),
autoprefixer({ browsers: pkg.browserlist }),
postcssReporter(),
]
},
}