This repository has been archived by the owner on Dec 14, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
141 lines (129 loc) · 3.57 KB
/
webpack.config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
require('es6-promise').polyfill();
import webpackStaticEntryPoints from 'webpack-static-entry-points';
var webpack = require('webpack');
var path = require('path');
var create = require('lodash/object/create');
var ExtractTextPlugin = require("extract-text-webpack-plugin");
var autoprefixer = require('autoprefixer');
var mqpacker = require('css-mqpacker');
var csswring = require('csswring');
var SRC = './src/trc quiz maker/client/client.js';
var DEST = './src/trc quiz maker/public/';
//
// Loaders
//
var JS_LOADER = {
test: /\.jsx?$/,
exclude: /node_modules\/(?!trc-quiz-maker)/,
loaders: ['babel']
};
var JSON_LOADER = {
test: /\.json$/,
loader: 'json-loader'
};
var FONT_LOADER = {
test: /\.(otf|woff|woff2|eot|ttf|svg)$/,
loader: 'url-loader',
query: {
limit: '10000',
name: '[name].[ext]'
}
};
//
// Development/base configuration
//
var development = {
devtool: 'source-map',
cache: true,
entry: [
'webpack-hot-middleware/client?http://0.0.0.0:3000',
SRC
],
output: {
path: path.resolve(__dirname, DEST),
filename: 'trc-quiz-maker.js',
publicPath: '/'
},
resolve: {
alias: {
react: path.join(__dirname, 'node_modules', 'react')
},
extensions: ['', '.js', '.jsx']
},
plugins: [
new webpack.HotModuleReplacementPlugin(),
new webpack.NoErrorsPlugin(),
new webpack.DefinePlugin({'process.env': {NODE_ENV: JSON.stringify(process.env.NODE_ENV || "development")}})
],
module: {
loaders: [
JS_LOADER,
JSON_LOADER,
FONT_LOADER,
{
test: /\.scss$/,
loaders: ["style-loader", "css-loader", "postcss-loader", "sass-loader"]
}
]
},
postcss: function() {
return [
autoprefixer({browsers: ['last 2 version', 'ie 9']})
];
},
eslint: {
configFile: '.eslintrc',
formatter: require('eslint-simple-formatter')
}
};
//
// Production config
// Extends the development options and then tweaks some things
//
// Uglyfies and merges components
// Uses the extract text plugin to serve uninlined css
// Minifies css and packs medai queries together
// Uses the external builds for core libraries
//
var production = create(development, {
devtool: undefined,
cache: false,
entry: SRC,
plugins: [
new webpack.optimize.DedupePlugin(),
new webpack.optimize.OccurenceOrderPlugin(),
new webpack.optimize.AggressiveMergingPlugin(),
new webpack.optimize.UglifyJsPlugin(),
new webpack.DefinePlugin({'process.env': {NODE_ENV: process.env.NODE_ENV || JSON.stringify('production')}}),
new ExtractTextPlugin("trc-quiz-maker.css")
],
module: {
loaders: [
JS_LOADER,
JSON_LOADER,
FONT_LOADER,
{
test: /\.scss$/,
loader: ExtractTextPlugin.extract("style-loader", "css-loader!postcss-loader!sass-loader")
}
]
},
postcss: function () {
return [
autoprefixer({browsers: ['last 2 version', 'ie 9']}),
mqpacker,
csswring
];
},
externals: {
react: 'React',
'react/addons': 'React',
'react-dom': 'ReactDOM',
immutable: 'Immutable'
}
});
module.exports = {
development: development,
production: production,
static: webpackStaticEntryPoints(development, './content/*', './src/trc-quiz-maker/static/staticRender.js')
};