Skip to content

Commit

Permalink
Fixes #19478 - migrate to webpack2
Browse files Browse the repository at this point in the history
  • Loading branch information
Matan Werbner committed Jun 20, 2017
1 parent bbb1b90 commit 66df468
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 25 deletions.
41 changes: 24 additions & 17 deletions config/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,21 @@
var path = require('path');
var webpack = require('webpack');
var StatsPlugin = require('stats-webpack-plugin');
var ExtractTextPlugin = require("extract-text-webpack-plugin");
var ExtractTextPlugin = require('extract-text-webpack-plugin');
var CompressionPlugin = require('compression-webpack-plugin');

// must match config.webpack.dev_server.port
var devServerPort = 3808;

// set TARGETNODE_ENV=production on the environment to add asset fingerprints
var production = process.env.RAILS_ENV === 'production' || process.env.NODE_ENV === 'production';
var production =
process.env.RAILS_ENV === 'production' ||
process.env.NODE_ENV === 'production';

var config = {
entry: {
// Sources are expected to live in $app_root/webpack
'bundle': './webpack/assets/javascripts/bundle.js'
bundle: './webpack/assets/javascripts/bundle.js'
},

output: {
Expand All @@ -30,8 +32,10 @@ var config = {
},

resolve: {
extensions: ['', '.js'],
root: path.join(__dirname, '..', 'webpack')
modules: [
path.join(__dirname, '..', 'webpack'),
path.join(__dirname, '..', 'node_modules')
]
},

module: {
Expand All @@ -43,18 +47,21 @@ var config = {
},
{
test: /\.css$/,
loader: ExtractTextPlugin.extract("style-loader", "css-loader")
loader: ExtractTextPlugin.extract({
fallback: 'style-loader',
use: 'css-loader'
})
},
{
test: /(\.png|\.gif)$/,
loader: "url-loader?limit=32767"
loader: 'url-loader?limit=32767'
},
{
test: /\.scss$/,
loader: ExtractTextPlugin.extract(
'style-loader', // The backup style loader
'css-loader?sourceMap!sass-loader?sourceMap'
)
loader: ExtractTextPlugin.extract({
fallback: 'style-loader', // The backup style loader
use: 'css-loader?sourceMap!sass-loader?sourceMap'
})
}
]
},
Expand All @@ -69,8 +76,9 @@ var config = {
modules: false,
assets: true
}),
new ExtractTextPlugin(production ? '[name]-[chunkhash].css' : '[name].css', {
allChunks: true
new ExtractTextPlugin({
filename: production ? '[name]-[chunkhash].css' : '[name].css',
allChunks: true
}),
new webpack.DefinePlugin({
'process.env': {
Expand All @@ -83,14 +91,13 @@ var config = {

if (production) {
config.plugins.push(
new webpack.NoErrorsPlugin(),
new webpack.NoEmitOnErrorsPlugin(),
new webpack.optimize.UglifyJsPlugin({
compressor: { warnings: false },
sourceMap: false
}),

new webpack.optimize.DedupePlugin(),
new webpack.optimize.OccurenceOrderPlugin(),
new webpack.optimize.ModuleConcatenationPlugin(),
new webpack.optimize.OccurrenceOrderPlugin(),
new CompressionPlugin()
);
} else {
Expand Down
7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
"eslint": "^3.3.1",
"eslint-plugin-react": "^6.1.2",
"expose-loader": "~0.6.0",
"extract-text-webpack-plugin": "^1.0.1",
"file-loader": "^0.9.0",
"identity-obj-proxy": "^3.0.0",
"jest-cli": "^20.0.0",
Expand All @@ -34,10 +33,10 @@
"react-test-renderer": "^15.5.4",
"redux-mock-store": "^1.2.2",
"sass-loader": "~4.1.1",
"stats-webpack-plugin": "^0.2.1",
"stats-webpack-plugin": "^0.6.0",
"style-loader": "^0.13.1",
"url-loader": "^0.5.7",
"webpack": "^1.9.11",
"webpack": "^3.0.0",
"webpack-dev-server": "^1.9.0"
},
"optionalDependencies": {
Expand All @@ -49,6 +48,7 @@
"datatables.net": "~1.10.12",
"datatables.net-bs": "~1.10.12",
"diff": "~3.0.0",
"extract-text-webpack-plugin": "^2.1.0",
"ipaddr.js": "~1.2.0",
"jquery": "~2.2.4",
"jquery-flot": "~0.8.3",
Expand All @@ -58,6 +58,7 @@
"lodash": "~4.15.0",
"multiselect": "~0.9.12",
"prop-types": "^15.5.9",
"fbjs": "0.8.12",
"react": "^15.1.0",
"react-bootstrap": "^0.31.0",
"react-dom": "^15.1.0",
Expand Down
10 changes: 5 additions & 5 deletions webpack/assets/javascripts/bundle.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
require('expose?$!expose?jQuery!jquery');
require('expose-loader?$!expose-loader?jQuery!jquery');
require('jquery-ujs');
require('expose?_!lodash');
require('expose?jstz!jstz');
require('expose?ipaddr!ipaddr.js');
require('expose-loader?_!lodash');
require('expose-loader?jstz!jstz');
require('expose-loader?ipaddr!ipaddr.js');
require('jquery.cookie');
require('expose?JsDiff!diff');
require('expose-loader?JsDiff!diff');
require('./bundle_flot');
require('./bundle_multiselect');
require('./bundle_select2');
Expand Down

0 comments on commit 66df468

Please sign in to comment.