Skip to content
This repository has been archived by the owner on Sep 1, 2020. It is now read-only.

Commit

Permalink
support for webpack2
Browse files Browse the repository at this point in the history
  • Loading branch information
vkbansal committed Feb 7, 2017
1 parent a01e1fe commit a7577d5
Show file tree
Hide file tree
Showing 4 changed files with 84 additions and 37 deletions.
27 changes: 21 additions & 6 deletions examples.config.js
Expand Up @@ -7,25 +7,40 @@ module.exports = {
entry: ["./examples/index.js"],
output: {
filename: "bundle.js",
sourceMapFileName: "bundle.js.map",
path: process.cwd(),
publicPath: "/"
},
resolve: {
root: path.resolve(__dirname)
modules: [
path.resolve(__dirname),
'node_modules'
]
},
module: {
loaders: [
rules: [
{
test: /\.js$/,
loader: "babel",
exclude: /node_modules/
loader: "babel-loader",
options: {
presets: [
'react',
['es2015', {
modules: false
}]
],
plugins: [
'transform-class-properties'
]
},
include: [
path.resolve(__dirname, './src'),
path.resolve(__dirname, './examples')
]
}
]
},
devtool: "source-map",
plugins: [
new webpack.optimize.OccurenceOrderPlugin(),
new webpack.optimize.UglifyJsPlugin({
compressor: {
warnings: false
Expand Down
64 changes: 43 additions & 21 deletions package.json
Expand Up @@ -3,6 +3,7 @@
"version": "2.1.0",
"description": "Context Menu implemented in React",
"main": "modules/index.js",
"module": "es6/index.js",
"keywords": [
"react",
"reactjs",
Expand All @@ -11,17 +12,17 @@
"rightclick"
],
"scripts": {
"eslint": "eslint ./src",
"eslint": "eslint ./src ./examples",
"coveralls": "cat ./reports/coverage/lcov.info | coveralls",
"test": "istanbul cover --dir reports/coverage node_modules/mocha/bin/_mocha test/.setup.js test/**/*-test.js -- --reporter dot",
"unit-test": "mocha test/.setup.js test/**/*-test.js",
"clean": "rimraf -rf ./dist && rimraf -rf ./modules",
"clean": "rimraf -rf ./dist && rimraf -rf ./modules && rimraf ./es6",
"start": "node server.js",
"dist": "webpack --progress --profile --colors",
"module": "babel src --out-dir modules",
"build": "npm run clean && npm run dist && npm run module",
"examples": "webpack --config examples.config.js --progress --profile --colors",
"watch": "./node_modules/.bin/webpack --config examples.config.js --progress --profile --colors --watch",
"modules": "BABEL_ENV=es5 babel src --out-dir modules",
"modules:es6": "BABEL_ENV=es6 babel src --out-dir es6",
"build": "npm run clean && npm run eslint && npm run dist && npm run modules && npm run modules:es6",
"examples": "NODE_ENV=production webpack --config examples.config.js --progress --profile --colors",
"prepublish": "npm run build"
},
"author": "Vivek Kumar Bansal <contact@vkbansal.me>",
Expand All @@ -43,24 +44,25 @@
"react-dom": "^0.14.0 || ^15.0.0"
},
"devDependencies": {
"babel-cli": "^6.18.0",
"babel-core": "^6.18.0",
"babel-cli": "^6.22.2",
"babel-core": "^6.22.1",
"babel-eslint": "^7.1.1",
"babel-loader": "^6.2.5",
"babel-preset-es2015": "^6.18.0",
"babel-preset-react": "^6.16.0",
"babel-loader": "^6.2.10",
"babel-preset-es2015": "^6.22.0",
"babel-preset-es2016": "^6.18.0",
"babel-preset-react": "^6.22.0",
"babel-preset-react-hmre": "^1.1.1",
"babel-preset-stage-0": "^6.16.0",
"babel-register": "^6.18.0",
"babel-preset-stage-2": "^6.22.0",
"babel-register": "^6.22.0",
"chai": "^3.5.0",
"chai-enzyme": "^0.5.2",
"coveralls": "^2.11.13",
"enzyme": "^2.6.0",
"eslint": "^3.11.1",
"eslint-config-vkbansal": "^4.1.0",
"eslint-import-resolver-webpack": "^0.7.0",
"enzyme": "^2.7.1",
"eslint": "^3.14.1",
"eslint-config-vkbansal": "^4.3.1",
"eslint-import-resolver-webpack": "^0.8.1",
"eslint-plugin-import": "^2.2.0",
"eslint-plugin-react": "^6.8.0",
"eslint-plugin-react": "^6.9.0",
"eslint-plugin-standard": "^2.0.1",
"express": "^4.14.0",
"history": "^4.4.1",
Expand All @@ -74,8 +76,28 @@
"react-router": "^3.0.0",
"rimraf": "^2.5.4",
"sinon": "^1.17.5",
"webpack": "^1.14.0",
"webpack-dev-middleware": "^1.8.4",
"webpack-hot-middleware": "^2.13.0"
"webpack": "^2.2.1",
"webpack-dev-middleware": "^1.10.0",
"webpack-hot-middleware": "^2.16.1"
},
"babel": {
"presets": [
"react"
],
"plugins": [
"transform-class-properties"
],
"env": {
"es6": {
"presets": [
"es2016"
]
},
"es5": {
"presets": [
"es2015"
]
}
}
}
}
6 changes: 2 additions & 4 deletions server.js
@@ -1,17 +1,15 @@
/* eslint-disable */
"use strict";

var express = require("express"),
path = require("path"),
webpack = require("webpack"),
config = require("./examples.config");

config.module.loaders[0].query = {presets: ["react-hmre"]};
config.module.rules[0].options.presets.splice(1, 0, ['react-hmre']);
config.entry.unshift("webpack-hot-middleware/client");

config.plugins = [
new webpack.HotModuleReplacementPlugin(),
new webpack.NoErrorsPlugin()
new webpack.NoEmitOnErrorsPlugin()
];

var app = express();
Expand Down
24 changes: 18 additions & 6 deletions webpack.config.js
@@ -1,6 +1,6 @@
/* eslint-disable */

var webpack = require("webpack");
const webpack = require('webpack');
const path = require('path');

module.exports = {
entry: "./src/index.js",
Expand All @@ -10,11 +10,24 @@ module.exports = {
library: 'ReactContextMenu'
},
module: {
loaders: [
rules: [
{
test: /\.js$/,
loaders: ["babel"],
exclude: /node_modules/
loader: "babel-loader",
options: {
presets: [
'react',
['es2015', {
modules: false
}]
],
plugins: [
'transform-class-properties'
]
},
include: [
path.resolve(__dirname, './src')
]
}
]
},
Expand All @@ -33,7 +46,6 @@ module.exports = {
}
}],
plugins: [
new webpack.optimize.OccurenceOrderPlugin(),
new webpack.DefinePlugin({
"process.env": {
"NODE_ENV": JSON.stringify("production")
Expand Down

0 comments on commit a7577d5

Please sign in to comment.