Skip to content

Commit

Permalink
update webpack
Browse files Browse the repository at this point in the history
  • Loading branch information
eightypop committed Sep 30, 2017
1 parent 307b31d commit 8380bd9
Show file tree
Hide file tree
Showing 8 changed files with 6,424 additions and 1,633 deletions.
2,984 changes: 1,378 additions & 1,606 deletions dist/react-responsive.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/react-responsive.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/react-responsive.min.js

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
"babel-cli": "^6.18.0",
"babel-core": "^6.18.0",
"babel-eslint": "^8.0.0",
"babel-loader": "^6.2.7",
"babel-loader": "^7.1.2",
"babel-plugin-add-module-exports": "^0.2.1",
"babel-plugin-transform-class-properties": "^6.24.1",
"babel-plugin-transform-object-rest-spread": "^6.26.0",
Expand All @@ -58,8 +58,8 @@
"react-dom": "^0.14.0 || ^15.0.0",
"should": "^13.0.1",
"sinon": "^3.2.1",
"webpack": "^1.13.3",
"webpack-dev-server": "^1.16.2"
"webpack": "^3.5.6",
"webpack-dev-server": "^2.8.1"
},
"scripts": {
"preversion": "npm run clean && npm run build && npm docs",
Expand Down
15 changes: 7 additions & 8 deletions samples/sandbox/src/index.jsx → samples/sandbox/src/index.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
/* global document, window */

'use strict';

var MediaQuery = require('../../../src');
var React = require('react');
var ReactDOM = require('react-dom');
window.React = React; // for dev
var MediaQuery = require('index')
var React = require('react')
var ReactDOM = require('react-dom')
window.React = React // for dev

var App = React.createClass({
displayName: 'demo',
Expand Down Expand Up @@ -36,8 +35,8 @@ var App = React.createClass({
<div>You are retina</div>
</MediaQuery>
</div>
);
)
}
});
})

ReactDOM.render(<App/>, document.getElementById('main'));
ReactDOM.render(<App/>, document.getElementById('main'))
32 changes: 21 additions & 11 deletions webpack.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
const path = require('path')
const webpack = require('webpack')

const plugins = [new webpack.EnvironmentPlugin({
NODE_ENV: process.env.BUILD_MODE == 'umd-min' ? 'production' : 'development'
})]

module.exports = {
entry: './src/index.js',
output: {
Expand All @@ -15,20 +19,26 @@ module.exports = {
'react': 'umd react',
'react-dom': 'umd react-dom'
},
plugins: [
new webpack.optimize.OccurenceOrderPlugin(),
new webpack.optimize.DedupePlugin(),
...((process.env.BUILD_MODE == 'umd-min') ?
[new webpack.optimize.UglifyJsPlugin()] : [])
],
plugins: process.env.BUILD_MODE == 'umd-min' ? [
...plugins,
new webpack.optimize.UglifyJsPlugin({
sourceMap: true,
parellel: true
})
] : plugins,
resolve: {
extensions: [ '', '.js' ],
root: path.resolve('src'),
modulesDirectory: 'node_modules'
modules: [
path.resolve('src'),
'node_modules'
]
},
module: {
loaders: [
{ test: [ /\.js$/, /\.jsx$/ ], loader: 'babel', exclude: /node_modules/ }
rules: [
{ test: [ /\.js$/, /\.jsx$/ ], use: 'babel-loader', exclude: /node_modules/ }
]
},
node: {
process: false,
setImmediate: false
}
}
12 changes: 9 additions & 3 deletions webpack.config.samples.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
const path = require('path')
const webpack = require('webpack')
const conf = require('./webpack.config')
delete conf.externals
conf.entry = [ './samples/sandbox/src/index.jsx', 'webpack-dev-server/client?http://0.0.0.0:3333', 'webpack/hot/only-dev-server' ]
conf.entry = './samples/sandbox/src/index.js'
conf.output = {
path: path.join(__dirname, 'serve'),
filename: 'sample.js'
}
conf.devServer = {
compress: true,
hot: true,
disableHostCheck: true
}
conf.plugins = [...conf.plugins, new webpack.HotModuleReplacementPlugin()]
conf.cache = true
conf.debug = true
conf.devtool = 'source-map'
conf.devtool = 'inline-source-map'

module.exports = conf
Loading

0 comments on commit 8380bd9

Please sign in to comment.