forked from ruanyf/webpack-demos
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
33 changed files
with
264 additions
and
201 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1 @@ | ||
document.write('<h1>Hello World</h1>'); | ||
|
||
if (__DEV__) { | ||
document.write(new Date()); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,17 @@ | ||
var webpack = require('webpack'); | ||
|
||
var devFlagPlugin = new webpack.DefinePlugin({ | ||
__DEV__: JSON.stringify(JSON.parse(process.env.DEBUG || 'false')) | ||
}); | ||
var HtmlwebpackPlugin = require('html-webpack-plugin'); | ||
var OpenBrowserPlugin = require('open-browser-webpack-plugin'); | ||
|
||
module.exports = { | ||
entry: './main.js', | ||
output: { | ||
filename: 'bundle.js' | ||
}, | ||
plugins: [devFlagPlugin] | ||
plugins: [ | ||
new HtmlwebpackPlugin({ | ||
title: 'Webpack-demos' | ||
}), | ||
new OpenBrowserPlugin({ | ||
url: 'http://localhost:8080' | ||
}) | ||
] | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
<html> | ||
<body> | ||
<script src="bundle.js"></script> | ||
<body> | ||
<body> | ||
<script src="bundle.js"></script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,5 @@ | ||
require.ensure(['./a'], function(require) { | ||
var content = require('./a'); | ||
document.open(); | ||
document.write('<h1>' + content + '</h1>'); | ||
document.close(); | ||
}); | ||
document.write('<h1>Hello World</h1>'); | ||
|
||
if (__DEV__) { | ||
document.write(new Date()); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,13 @@ | ||
var webpack = require('webpack'); | ||
|
||
var devFlagPlugin = new webpack.DefinePlugin({ | ||
__DEV__: JSON.stringify(JSON.parse(process.env.DEBUG || 'false')) | ||
}); | ||
|
||
module.exports = { | ||
entry: './main.js', | ||
output: { | ||
filename: 'bundle.js' | ||
} | ||
}, | ||
plugins: [devFlagPlugin] | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,6 @@ | ||
var load = require('bundle-loader!./a.js'); | ||
|
||
load(function(file) { | ||
require.ensure(['./a'], function(require) { | ||
var content = require('./a'); | ||
document.open(); | ||
document.write('<h1>' + file + '</h1>'); | ||
document.write('<h1>' + content + '</h1>'); | ||
document.close(); | ||
}); |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,5 @@ | ||
<html> | ||
<body> | ||
<div id="a"></div> | ||
<div id="b"></div> | ||
<script src="init.js"></script> | ||
<script src="bundle1.js"></script> | ||
<script src="bundle2.js"></script> | ||
</body> | ||
<script src="bundle.js"></script> | ||
<body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
var load = require('bundle-loader!./a.js'); | ||
|
||
load(function(file) { | ||
document.open(); | ||
document.write('<h1>' + file + '</h1>'); | ||
document.close(); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,6 @@ | ||
var CommonsChunkPlugin = require("webpack/lib/optimize/CommonsChunkPlugin"); | ||
module.exports = { | ||
entry: { | ||
bundle1: './main1.jsx', | ||
bundle2: './main2.jsx' | ||
}, | ||
entry: './main.js', | ||
output: { | ||
filename: '[name].js' | ||
}, | ||
module: { | ||
loaders:[ | ||
{ test: /\.js[x]?$/, exclude: /node_modules/, loader: 'babel-loader' }, | ||
] | ||
}, | ||
plugins: [ | ||
new CommonsChunkPlugin('init.js') | ||
] | ||
} | ||
filename: 'bundle.js' | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,9 @@ | ||
<html> | ||
<body> | ||
<h1></h1> | ||
<script src="vendor.js"></script> | ||
<script src="bundle.js"></script> | ||
<div id="a"></div> | ||
<div id="b"></div> | ||
<script src="init.js"></script> | ||
<script src="bundle1.js"></script> | ||
<script src="bundle2.js"></script> | ||
</body> | ||
</html> |
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,18 @@ | ||
var webpack = require('webpack'); | ||
|
||
var CommonsChunkPlugin = require("webpack/lib/optimize/CommonsChunkPlugin"); | ||
module.exports = { | ||
entry: { | ||
app: './main.js', | ||
vendor: ['jquery'], | ||
bundle1: './main1.jsx', | ||
bundle2: './main2.jsx' | ||
}, | ||
output: { | ||
filename: 'bundle.js' | ||
filename: '[name].js' | ||
}, | ||
module: { | ||
loaders:[ | ||
{ test: /\.js[x]?$/, exclude: /node_modules/, loader: 'babel-loader' }, | ||
] | ||
}, | ||
plugins: [ | ||
new webpack.optimize.CommonsChunkPlugin(/* chunkName= */'vendor', /* filename= */'vendor.js') | ||
new CommonsChunkPlugin('init.js') | ||
] | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
<html> | ||
<body> | ||
<script src="data.js"></script> | ||
<h1></h1> | ||
<script src="vendor.js"></script> | ||
<script src="bundle.js"></script> | ||
</body> | ||
</html> |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,14 @@ | ||
var webpack = require('webpack'); | ||
|
||
module.exports = { | ||
entry: './main.jsx', | ||
entry: { | ||
app: './main.js', | ||
vendor: ['jquery'], | ||
}, | ||
output: { | ||
filename: 'bundle.js' | ||
}, | ||
module: { | ||
loaders:[ | ||
{ test: /\.js[x]?$/, exclude: /node_modules/, loader: 'babel-loader' }, | ||
] | ||
}, | ||
externals: { | ||
// require("jquery") is external and available | ||
// on the global var jQuery | ||
// "jquery": "jQuery" | ||
'data': 'data' | ||
} | ||
plugins: [ | ||
new webpack.optimize.CommonsChunkPlugin(/* chunkName= */'vendor', /* filename= */'vendor.js') | ||
] | ||
}; |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
<html> | ||
<body> | ||
<div id='root'></div> | ||
<script src="/static/bundle.js"></script> | ||
<script src="data.js"></script> | ||
<script src="bundle.js"></script> | ||
</body> | ||
</html> |
This file was deleted.
Oops, something went wrong.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,17 @@ | ||
var webpack = require('webpack'); | ||
var path = require('path'); | ||
|
||
module.exports = { | ||
entry: [ | ||
'webpack-dev-server/client?http://localhost:8080', | ||
'webpack/hot/only-dev-server', | ||
'./index.js' | ||
], | ||
entry: './main.jsx', | ||
output: { | ||
filename: 'bundle.js', | ||
publicPath: '/static/' | ||
filename: 'bundle.js' | ||
}, | ||
plugins: [ | ||
new webpack.HotModuleReplacementPlugin(), | ||
new webpack.NoErrorsPlugin() | ||
], | ||
module: { | ||
loaders: [{ | ||
test: /\.jsx?$/, | ||
loaders: ['react-hot-loader', 'babel-loader'], | ||
include: path.join(__dirname, '.') | ||
}] | ||
loaders:[ | ||
{ test: /\.js[x]?$/, exclude: /node_modules/, loader: 'babel-loader' }, | ||
] | ||
}, | ||
externals: { | ||
// require("jquery") is external and available | ||
// on the global var jQuery | ||
// "jquery": "jQuery" | ||
'data': 'data' | ||
} | ||
}; |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
<html> | ||
<body> | ||
<script src="bundle.js"></script> | ||
<div id='root'></div> | ||
<script src="/static/bundle.js"></script> | ||
</body> | ||
</htmL> | ||
</html> |
Oops, something went wrong.