Skip to content

Commit

Permalink
Fix webpack config
Browse files Browse the repository at this point in the history
  • Loading branch information
i-kitaev committed Jun 30, 2016
1 parent b445bea commit 2861214
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 38 deletions.
14 changes: 7 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
{
"name": "react-summernote",
"version": "1.0.0-rc2",
"version": "1.0.0-rc3",
"description": "Summernote adaptation for react",
"main": "./dist/summernote.js",
"main": "./dist/react-summernote.js",
"repository": {
"type": "git",
"url": "https://github.com/Vnkitaev/react-summernote.git"
},
"scripts": {
"compile": "webpack --config ./webpack.config.js",
"compile:production": "NODE_ENV=production webpack --config ./webpack.config.js"
"compile": "webpack --config ./webpack.config.js"
},
"keywords": [
"summernote",
Expand All @@ -25,11 +24,11 @@
"license": "MIT",
"readmeFilename": "README.md",
"dependencies": {
"codemirror": "5.16.0",
"summernote-webpack-fix": "0.8.2"
"summernote-webpack-fix": "^0.8.1",
"codemirror": "^5.11.0"
},
"peerDependencies": {
"jquery": "3.0.0",
"jquery": "^2.2.0",
"bootstrap": "^3.3.6",
"react": "*",
"react-dom": "*"
Expand All @@ -45,6 +44,7 @@
"style-loader": "0.13.1",
"css-loader": "0.23.1",
"extract-text-webpack-plugin": "1.0.1",
"copy-webpack-plugin": "3.0.1",
"eslint": "2.13.1",
"eslint-config-airbnb": "9.0.1",
"eslint-plugin-react": "5.2.2",
Expand Down
5 changes: 2 additions & 3 deletions src/Summernote.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
import "bootstrap/js/modal";
import "bootstrap/js/dropdown";
import "bootstrap/js/tooltip";
import "bootstrap/js/popover";
import "summernote-webpack-fix";
import "summernote-webpack-fix/dist/summernote";
import "summernote-webpack-fix/dist/summernote.css";
import "codemirror/lib/codemirror.css";
import React from "react";
Expand All @@ -25,7 +24,7 @@ class ReactSummernote extends React.Component {
constructor(props) {
super(props);

this.uid = `reactSummernote-${Date.now()}`;
this.uid = `react-summernote-${Date.now()}`;
this.editor = {};

ReactSummernote.insertImage = ReactSummernote.insertImage.bind(this);
Expand Down
40 changes: 12 additions & 28 deletions webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,15 @@
const path = require("path");
const webpack = require("webpack");
const ExtractTextPlugin = require("extract-text-webpack-plugin");
const CopyWebpackPlugin = require("copy-webpack-plugin");

const src = path.join(__dirname, "src");
const dist = path.join(__dirname, "dist");
const isProduction = process.env.NODE_ENV === "production";
const extractCSS = new ExtractTextPlugin("[name].css");

const baseConfig = {
module.exports = {
context: __dirname,
entry: {
summernote: path.join(src, "Summernote.jsx")
"react-summernote": path.join(src, "Summernote.jsx")
},
output: {
path: dist,
Expand All @@ -39,7 +38,14 @@ const baseConfig = {
"bootstrap/js/tooltip": "bootstrap/js/tooltip"
}],
plugins: [
extractCSS
new webpack.ProvidePlugin({
$: "jquery",
jQuery: "jquery"
}),
new CopyWebpackPlugin([{
from: "node_modules/summernote-webpack-fix/dist/lang", to: "lang"
}]),
new ExtractTextPlugin("[name].css")
],
module: {
loaders: [
Expand All @@ -53,7 +59,7 @@ const baseConfig = {
},
{
test: /\.(css)(\?.+)?$/,
loader: extractCSS.extract("style", "css")
loader: ExtractTextPlugin.extract("style", "css")
},
{
test: /\.(otf|eot|svg|ttf|woff|woff2)(\?.+)?$/,
Expand All @@ -62,25 +68,3 @@ const baseConfig = {
]
}
};

const productionConfig = Object.assign({}, baseConfig);
productionConfig.output.filename = "[name].min.js";
productionConfig.plugins = baseConfig.plugins.concat([
new webpack.DefinePlugin({
process: {
env: {
NODE_ENV: JSON.stringify("production")
}
}
}),
new webpack.optimize.UglifyJsPlugin({
output: {
comments: false
},
compress: {
drop_console: true
}
})
]);

module.exports = !isProduction ? baseConfig : productionConfig;

0 comments on commit 2861214

Please sign in to comment.