This commit is contained in:
Cmdr McDonald
2017-02-25 14:45:47 +00:00
parent a9fdf73d86
commit 4bf30c0cd5

View File

@@ -6,11 +6,11 @@ var HtmlWebpackPlugin = require("html-webpack-plugin");
var ExtractTextPlugin = require("extract-text-webpack-plugin"); var ExtractTextPlugin = require("extract-text-webpack-plugin");
var AppCachePlugin = require('appcache-webpack-plugin'); var AppCachePlugin = require('appcache-webpack-plugin');
var node_modules_dir = path.resolve(__dirname, 'node_modules'); //var node_modules_dir = path.resolve(__dirname, 'node_modules');
var d3Path = path.resolve(__dirname, 'd3.min.js'); //var d3Path = path.resolve(__dirname, 'd3.min.js');
var reactPath = path.resolve(node_modules_dir, 'react/dist/react.min.js'); //var reactPath = path.resolve(node_modules_dir, 'react/dist/react.min.js');
var reactDomPath = path.resolve(node_modules_dir, 'react-dom/dist/react-dom.min.js'); //var reactDomPath = path.resolve(node_modules_dir, 'react-dom/dist/react-dom.min.js');
var lzStringPath = path.resolve(node_modules_dir, 'lz-string/libs/lz-string.min.js'); //var lzStringPath = path.resolve(node_modules_dir, 'lz-string/libs/lz-string.min.js');
function CopyDirPlugin(source, destination) { function CopyDirPlugin(source, destination) {
this.source = source; this.source = source;
@@ -26,16 +26,16 @@ CopyDirPlugin.prototype.apply = function(compiler) {
module.exports = { module.exports = {
entry: { entry: {
app: ['babel-polyfill', path.resolve(__dirname, 'src/app/index')], app: ['babel-polyfill', path.resolve(__dirname, 'src/app/index')],
lib: ['babel-polyfill', 'd3', 'react', 'react-dom', 'classnames', 'fbemitter', 'lz-string'] lib: ['d3', 'react', 'react-dom', 'classnames', 'fbemitter', 'lz-string']
}, },
resolve: { resolve: {
extensions: ['.js', '.jsx', '.json', '.less'], extensions: ['.js', '.jsx', '.json', '.less'],
alias: { // alias: {
'd3': d3Path, // 'd3': d3Path,
'react': reactPath, // 'react': reactPath,
'react-dom': reactDomPath, // 'react-dom': reactDomPath,
'lz-string': lzStringPath // 'lz-string': lzStringPath
}, // },
}, },
output: { output: {
path: path.join(__dirname, 'build'), path: path.join(__dirname, 'build'),
@@ -51,10 +51,10 @@ module.exports = {
}, },
'screw-ie8': true 'screw-ie8': true
}), }),
new webpack.optimize.CommonsChunkPlugin({ //new webpack.optimize.CommonsChunkPlugin({
name: 'lib', // name: 'lib',
filename: 'lib.[chunkhash:6].js' // filename: 'lib.[chunkhash:6].js'
}), //}),
new HtmlWebpackPlugin({ new HtmlWebpackPlugin({
inject: false, inject: false,
appCache: 'coriolis.appcache', appCache: 'coriolis.appcache',
@@ -90,12 +90,15 @@ module.exports = {
}) })
], ],
module: { module: {
noParse: /.*\.min\.js$/, //noParse: /.*\.min\.js$/,
rules: [ rules: [
// Expose non-parsed globally scoped libs // Expose non-parsed globally scoped libs
{ test: reactPath, loader: "expose-loader?React" }, //{ test: reactPath, loader: "expose-loader?React" },
{ test: d3Path, loader: "expose-loader?d3" }, //{ test: d3Path, loader: "expose-loader?d3" },
{ test: lzStringPath, loader: "expose-loader?LZString" }, //{ test: lzStringPath, loader: "expose-loader?LZString" },
//{ test: reactPath, use: [ { loader: 'expose-loader', options: 'React' } ] },
//{ test: d3Path, use: [ { loader: 'expose-loader', options: 'd3' } ] },
//{ test: lzStringPath, use: [ { loader: 'expose-loader', options: 'LZString' } ] },
{ test: /\.css$/, loader: ExtractTextPlugin.extract({ fallback: 'style-loader', use: 'css-loader'}) }, { test: /\.css$/, loader: ExtractTextPlugin.extract({ fallback: 'style-loader', use: 'css-loader'}) },
{ test: /\.less$/, loader: ExtractTextPlugin.extract({ fallback: 'style-loader',use: 'css-loader!less-loader'}) }, { test: /\.less$/, loader: ExtractTextPlugin.extract({ fallback: 'style-loader',use: 'css-loader!less-loader'}) },