This repository was archived by the owner on Mar 7, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwebpack.config.js
More file actions
100 lines (91 loc) · 3.39 KB
/
webpack.config.js
File metadata and controls
100 lines (91 loc) · 3.39 KB
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
var path = require("path");
var webpack = require("webpack");
var ExtractTextPlugin = require("extract-text-webpack-plugin");
var autoprefixer = require('autoprefixer');
var BUILD_DIR = path.resolve(__dirname, 'public/scripts');
var APP_DIR = path.resolve(__dirname, 'src/');
//export config object
module.exports = {
//Start looking for files in our main js file, and fill in gaps using babel fill ins (polyfills)
entry: APP_DIR + '/index.jsx',
output: {
//Output bundle to ./public/javascripts/bundle.js
path: BUILD_DIR,
filename: "bundle.js",
//The location on the public path of your bundle file
publicPath: "/scripts"
},
node: {
fs: "empty"
},
module: {
loaders: [
//eslint loader
{
//make sure we lint before we transform code
enforce: "pre",
//only test js and jsx files
test: [/\.js$/, /\.jsx$/],
//only include files in the client directory (so we don't compile our node modules or server side code)
include: APP_DIR,
loader: 'eslint-loader',
},
//Babel javascript loader, convert jsx or js files to es5 javascript
{
//only test js and jsx files
test: [/\.js$/, /\.jsx$/],
//only include files in the client directory (so we don't compile our node modules or server side code)
include: APP_DIR,
loader: 'babel-loader',
query: {
//use es6 and or jsx syntax
presets: ['react', 'es2015'],
// makes output more concise
plugins: ['transform-runtime'],
}
},
//CSS loader: Allows you to import CSS and SASS files. This version runs postcss to add vendor prefixes and uses the CSS module pattern. We also run the extract text plugin to bundle the css into its own single file
//
//More information about the CSS Module pattern can be found:
//https://glenmaddern.com/articles/css-modules
//https://github.com/css-modules/css-modules
{
test: /\.css$/,
loader: 'style-loader'
},
{
test: /\.css$/,
loader: 'css-loader',
query: {
modules: true,
localIdentName: '[name]__[local]___[hash:base64:5]'
}
},
//Loader for .png and .jpg files
{
test: /\.(png|jpg)$/,
loader: 'url-loader?limit=8192&name=./public/images/[hash].[ext]'
}
]
},
// Set where we are going to extract the css bundle
plugins: [
new ExtractTextPlugin("./public/stylesheets/styles.css"),
new webpack.LoaderOptionsPlugin({
options: {
// configure the postcss loader to user autoprefixer
postcss: [ autoprefixer({ browsers:['last 2 versions'] }) ]
}
})
],
resolve: {
// look for modules in node_modules and the client directory for imports
modules: [
path.join(__dirname, ''),
'node_modules',
'client'
],
// resolve below file types
extensions: ['.js', '.jsx', 'css']
}
}