Skip to content

Commit

Permalink
webpack production build working, WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
daneryl committed Apr 16, 2017
1 parent 6e54b40 commit 0ba1a0d
Show file tree
Hide file tree
Showing 3 changed files with 78 additions and 27 deletions.
1 change: 1 addition & 0 deletions server.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable */
require('es6-promise').polyfill(); // Required in some browsers

//babel polyfill ES6
Expand Down
4 changes: 0 additions & 4 deletions webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@ var ExtractTextPlugin = require("extract-text-webpack-plugin");
module.exports = {
context: __dirname,
devtool: '#source-map',
//entry: [
//path.join(__dirname, 'app/react/index.js')
//],
entry: {
main: path.join(__dirname, 'app/react/index.js'),
'pdf.worker': path.join(__dirname, 'node_modules/pdfjs-dist/build/pdf.worker.entry'),
Expand All @@ -21,7 +18,6 @@ module.exports = {
filename: '[name].bundle.js'
},
module: {
//noParse: /node_modules/,
rules: [
{
test: /\.js$/,
Expand Down
100 changes: 77 additions & 23 deletions webpack.production.config.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable */
'use strict';

var path = require('path');
Expand All @@ -16,16 +17,77 @@ class CleanPlugin {
}

module.exports = {
entry: [
path.join(__dirname, 'app/react/index.js')
],
context: __dirname,
devtool: '#source-map',
entry: {
main: path.join(__dirname, 'app/react/index.js'),
'pdf.worker': path.join(__dirname, 'node_modules/pdfjs-dist/build/pdf.worker.entry'),
},
output: {
path: path.join(__dirname, '/dist/'),
filename: 'bundle.min.js'
publicPath: '/',
filename: '[name].bundle.js'
},
module: {
rules: [
{
test: /\.js$/,
loader: 'babel-loader?cacheDirectory',
include: path.join(__dirname, 'app'),
exclude: /node_modules/
},
{
test: /\.scss$/,
loader: ExtractTextPlugin.extract({
fallback: 'style-loader',
use: 'css-loader?sourceMap!sass-loader?outputStyle=expanded&sourceMap=true&sourceMapContents=true'
}),
include: [
path.join(__dirname, 'app'),
path.join(__dirname, 'node_modules/react-widgets/lib/scss/')
]
},
{
test: /\.css$/,
loader: ExtractTextPlugin.extract({
fallback: 'style-loader',
use: 'css-loader?sourceMap'
}),
include: [
path.join(__dirname, 'app'),
path.join(__dirname, 'node_modules/react-datepicker/dist/'),
path.join(__dirname, 'node_modules/bootstrap/dist/'),
path.join(__dirname, 'node_modules/font-awesome/css/'),
path.join(__dirname, 'node_modules/pdfjs-dist/web')
]
},
{
test: /\.(jpe?g|png|eot|woff|woff2|ttf|gif|svg)(\?.*)?$/i,
loaders: ['url-loader', 'img-loader'],
include: [
path.join(__dirname, 'public'),
path.join(__dirname, 'app'),
path.join(__dirname, 'node_modules/react-widgets/lib/fonts/'),
path.join(__dirname, 'node_modules/font-awesome/fonts/'),
path.join(__dirname, 'node_modules/react-widgets/lib/img/'),
path.join(__dirname, 'node_modules/pdfjs-dist/web/images/'),
path.join(__dirname, 'node_modules/pdfjs-dist/web/images/'),
path.join(__dirname, 'node_modules/bootstrap/dist/fonts/')
]
},
{
test:/\.json$/i,
loaders: ['json-loader'],
include: [
path.join(__dirname, 'app')
//path.join(__dirname, 'node_modules')
]
}
]
},
plugins: [
new ExtractTextPlugin('style.min.css'),
new webpack.optimize.OccurenceOrderPlugin(),
new ExtractTextPlugin('style.css'),
//new webpack.optimize.OccurenceOrderPlugin(),
new CleanPlugin({
files: ['dist/*']
}),
Expand All @@ -36,22 +98,14 @@ module.exports = {
}
}),
new webpack.DefinePlugin({
'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV)
'process.env': {
NODE_ENV: '"production"'
},

__CLIENT__: true,
__SERVER__: false,
__DEVELOPMENT__: false,
__DEVTOOLS__: false
})
],
module: {
loaders: [{
test: /\.js?$/,
loader: 'babel-loader',
include: path.join(__dirname, 'app/react'),
}, {
test: /\.scss$/,
loader: ExtractTextPlugin.extract('style', 'css', 'sass'),
include: path.join(__dirname, 'app')
}, {
test: /\.(jpe?g|png|eot|woff|ttf|gif|svg)(\?.*)?$/i,
loader: 'file-loader',
include: path.join(__dirname, 'app')
}]
}
]
};

0 comments on commit 0ba1a0d

Please sign in to comment.