|
| 1 | +//require our dependencies |
| 2 | +var path = require('path'); |
| 3 | +var webpack = require('webpack'); |
| 4 | +const {resolve} = require('path'); |
| 5 | +var BundleTracker = require('webpack-bundle-tracker'); |
| 6 | +const Dotenv = require('dotenv-webpack'); |
| 7 | +const UglifyJsPlugin = require('uglifyjs-webpack-plugin'); |
| 8 | +const ExtractTextPlugin = require('extract-text-webpack-plugin'); |
| 9 | +const APP_DIR = resolve(__dirname, 'assets/js/client'); |
| 10 | + |
| 11 | +module.exports = env => { |
| 12 | + return { |
| 13 | + //the base directory (abs. path) for resolving the entry option |
| 14 | + context: __dirname, |
| 15 | + entry: ['babel-polyfill', APP_DIR + '/ramascene.js'], |
| 16 | + |
| 17 | + output: { |
| 18 | + //where to store compiled bundle |
| 19 | + path: path.resolve(__dirname + '/assets/bundles/'), |
| 20 | + |
| 21 | + //webpack naming convention where files are stores |
| 22 | + filename: '[name]-[hash].js' |
| 23 | + }, |
| 24 | + |
| 25 | + plugins: [ |
| 26 | + //where to store meta-data about the bundle |
| 27 | + new BundleTracker({path: __dirname, filename: './webpack-stats.json'}), |
| 28 | + new ExtractTextPlugin({ |
| 29 | + filename: 'style.css', |
| 30 | + disable: false, |
| 31 | + allChunks: true |
| 32 | + |
| 33 | + }), |
| 34 | + new webpack.DefinePlugin({ |
| 35 | + 'process.env': { |
| 36 | + 'NODE_ENV': JSON.stringify('dev') |
| 37 | + } |
| 38 | + }), |
| 39 | + |
| 40 | + new webpack.DefinePlugin({ |
| 41 | + 'WEBSOCKET_URL': '"ws://127.0.0.1:8000/ramascene/"', |
| 42 | + 'AJAX_URL': '"http://127.0.0.1:8000/ajaxhandling/"' |
| 43 | + }) |
| 44 | + ], |
| 45 | + |
| 46 | + module: { |
| 47 | + loaders: [ |
| 48 | + { |
| 49 | + include: APP_DIR, |
| 50 | + loader: 'babel-loader', |
| 51 | + query: { |
| 52 | + //what will be dealing with (react code) |
| 53 | + presets: ['es2015', 'react'], |
| 54 | + plugins: ['transform-class-properties'] |
| 55 | + }, |
| 56 | + test: /\.js$/ |
| 57 | + }, |
| 58 | + { |
| 59 | + test: /\.(css|sass|scss)$/, |
| 60 | + use: ExtractTextPlugin.extract({fallback: 'style-loader', use: 'css-loader!sass-loader'}) |
| 61 | + }, |
| 62 | + { |
| 63 | + test: /\.woff2?$|\.ttf$|\.svg$|\.eot$/, |
| 64 | + use: [ |
| 65 | + { |
| 66 | + loader: 'file-loader' |
| 67 | + } |
| 68 | + ] |
| 69 | + } |
| 70 | + ] |
| 71 | + }, |
| 72 | + |
| 73 | + resolve: { |
| 74 | + //where to look for modules |
| 75 | + |
| 76 | + extensions: ['.js', '.jsx', '.css'] |
| 77 | + } |
| 78 | + } |
| 79 | +}; |
0 commit comments