2016-10-11 17:42:17 +00:00
|
|
|
let path = require("path");
|
|
|
|
let webpack = require('webpack');
|
|
|
|
let BundleTracker = require('webpack-bundle-tracker');
|
|
|
|
let ExtractTextPlugin = require('extract-text-webpack-plugin');
|
|
|
|
let LiveReloadPlugin = require('webpack-livereload-plugin');
|
2016-10-08 16:35:22 +00:00
|
|
|
|
2016-12-19 21:39:38 +00:00
|
|
|
let osgPath = path.resolve('app/static/app/js/vendor/osgjs');
|
|
|
|
|
2016-10-08 16:35:22 +00:00
|
|
|
module.exports = {
|
|
|
|
context: __dirname,
|
|
|
|
|
2016-10-11 17:42:17 +00:00
|
|
|
entry: [
|
|
|
|
// 'webpack-dev-server/client?http://localhost:3000',
|
|
|
|
// 'webpack/hot/only-dev-server',
|
|
|
|
'./app/static/app/js/main.jsx',
|
|
|
|
],
|
2016-10-08 16:35:22 +00:00
|
|
|
|
|
|
|
output: {
|
2016-10-11 17:42:17 +00:00
|
|
|
path: path.join(__dirname, './app/static/app/bundles/'),
|
|
|
|
filename: "[name]-[hash].js"
|
|
|
|
// publicPath: 'http://localhost:3000/app/static/app/bundles/', // Tell django to use this URL to load packages and not use STATIC_URL + bundle_name
|
2016-10-08 16:35:22 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
plugins: [
|
2016-10-11 17:42:17 +00:00
|
|
|
// new webpack.HotModuleReplacementPlugin(),
|
|
|
|
// new webpack.NoErrorsPlugin(), // don't reload if there is an error
|
|
|
|
new LiveReloadPlugin(),
|
2016-10-08 16:35:22 +00:00
|
|
|
new BundleTracker({filename: './webpack-stats.json'}),
|
2016-10-11 17:42:17 +00:00
|
|
|
new ExtractTextPlugin('css/main.css', {
|
|
|
|
allChunks: true
|
|
|
|
})
|
2016-10-08 16:35:22 +00:00
|
|
|
],
|
|
|
|
|
|
|
|
module: {
|
|
|
|
loaders: [
|
|
|
|
{
|
|
|
|
test: /\.jsx?$/,
|
|
|
|
exclude: /(node_modules|bower_components)/,
|
|
|
|
loader: 'babel-loader',
|
|
|
|
query: {
|
2016-11-09 21:13:43 +00:00
|
|
|
"plugins": [
|
|
|
|
'syntax-class-properties',
|
|
|
|
'transform-class-properties'
|
|
|
|
// 'react-hot-loader/babel'
|
|
|
|
],
|
2016-10-08 16:35:22 +00:00
|
|
|
presets: ['es2015', 'react']
|
|
|
|
}
|
2016-10-11 17:42:17 +00:00
|
|
|
},
|
|
|
|
{
|
2016-10-27 20:40:22 +00:00
|
|
|
test: /\.s?css$/,
|
2016-10-11 17:42:17 +00:00
|
|
|
loader: ExtractTextPlugin.extract('css!sass')
|
2016-11-09 21:13:43 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
test: /\.(png|jpg|jpeg|svg)/,
|
|
|
|
loader: "url-loader?limit=100000"
|
2016-12-19 21:39:38 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
// shaders
|
|
|
|
test: /\.(frag|vert|glsl)$/,
|
|
|
|
loader: 'raw-loader'
|
2016-10-08 16:35:22 +00:00
|
|
|
}
|
|
|
|
]
|
|
|
|
},
|
|
|
|
|
|
|
|
resolve: {
|
|
|
|
modulesDirectories: ['node_modules', 'bower_components'],
|
2016-12-19 21:39:38 +00:00
|
|
|
extensions: ['', '.js', '.jsx'],
|
|
|
|
|
|
|
|
alias: {
|
|
|
|
osg: path.join(osgPath, 'osg'),
|
|
|
|
osgNameSpace: path.join(osgPath, 'osgNameSpace.js'),
|
|
|
|
osgAnimation: path.join(osgPath, 'osgAnimation'),
|
|
|
|
osgDB: path.join(osgPath, 'osgDB'),
|
|
|
|
osgGA: path.join(osgPath, 'osgGA'),
|
|
|
|
osgPlugins: path.join(osgPath, 'osgPlugins'),
|
|
|
|
osgShader: path.join(osgPath, 'osgShader'),
|
|
|
|
osgShadow: path.join(osgPath, 'osgShadow'),
|
|
|
|
osgText: path.join(osgPath, 'osgText'),
|
|
|
|
osgUtil: path.join(osgPath, 'osgUtil'),
|
|
|
|
osgViewer: path.join(osgPath, 'osgViewer'),
|
|
|
|
osgWrappers: path.join(osgPath, 'osgWrappers')
|
|
|
|
}
|
2016-10-11 17:42:17 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
externals: {
|
2016-12-19 21:39:38 +00:00
|
|
|
// require("jquery") is external and available
|
|
|
|
// on the global let jQuery
|
|
|
|
"jquery": "jQuery",
|
|
|
|
"zlib" : "Zlib",
|
|
|
|
"bluebird": "P",
|
|
|
|
"rstats": "rStats",
|
|
|
|
"hammer": "Hammer"
|
2016-10-08 16:35:22 +00:00
|
|
|
}
|
|
|
|
}
|