Skip to content

Commit

Permalink
fix(): Resolving issue with compilation.
Browse files Browse the repository at this point in the history
closes #2
  • Loading branch information
mrsteele committed Aug 3, 2016
1 parent d397761 commit f71603d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
},
"homepage": "https://github.com/mrsteele/dotenv-webpack#readme",
"dependencies": {
"dotenv-safe": "^2.3.1",
"dotenv": "^2.0.0",
"webpack": "^1.13.0"
},
"devDependencies": {
Expand Down
8 changes: 3 additions & 5 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import dotenv from 'dotenv-safe'
import { parse } from 'dotenv'
import fs from 'fs'
import { DefinePlugin } from 'webpack'

Expand All @@ -7,16 +7,14 @@ class Dotenv {
options = options || {}
if (!options.path) options.path = './.env'

dotenv.config(options)
this.env = {}

try {
this.env = dotenv.parse(fs.readFileSync(options.path))
this.env = parse(fs.readFileSync(options.path))
} catch (err) {}
}

apply (compiler) {
const plugin = Object.keys(this.example).reduce((definitions, key) => {
const plugin = Object.keys(this.env).reduce((definitions, key) => {
const value = process.env[key] || this.env[key]
definitions[`process.env.${key}`] = JSON.stringify(value)
return definitions
Expand Down

0 comments on commit f71603d

Please sign in to comment.