-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathwebpack.config.js
157 lines (154 loc) · 4.84 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
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
'use strict'
const path = require('path')
const webpack = require('webpack')
const publicPath = path.resolve(__dirname, './src/client')
const buildPath = path.resolve(__dirname, './src')
// const BrowserSyncPlugin = require('browser-sync-webpack-plugin')
// const Write = require('write-file-webpack-plugin') */
process.noDeprecation = true
module.exports = {
devtool: 'source-maps',
performance: {
hints: false
},
/* To use server instead of proxy. To use Browsersync for mobile testing, use proxy. */
// devServer: {
// hot: true,
// port: 3001,
// host: 'localhost',
// headers: { 'Access-Control-Allow-Origin': '*' },
// historyApiFallback: true
// },
devServer: {
hot: true,
port: 3001,
host: 'localhost',
/* Needed only if using Browsersync */
headers: { 'Access-Control-Allow-Origin': '*' },
proxy: {
'**': {
target: 'http://localhost:3000',
secure: false,
changeOrigin: true
}
}
},
context: publicPath,
entry: {
bundle: [
'react-hot-loader/patch',
'webpack-dev-server/client?http://localhost:3001',
'webpack/hot/only-dev-server',
'script-loader!jquery/dist/jquery.min.js',
'script-loader!tether/dist/js/tether.min.js',
'script-loader!bootstrap/dist/js/bootstrap.min.js',
'./app.js'
]
},
output: {
path: path.join(buildPath, 'dist'),
filename: '[name].js',
publicPath: 'http://localhost:3001/'
},
resolve: {
extensions: ['.js', '.jsx'],
alias: {
FormComponent: path.resolve(__dirname, 'src/client/scenes/feature/components/FormComponent.jsx'),
Feature: path.resolve(__dirname, 'src/client/scenes/feature/index.jsx'),
TitleComponent: path.resolve(__dirname, 'src/client/scenes/home/components/TitleComponent.jsx'),
Home: path.resolve(__dirname, 'src/client/scenes/home/index.jsx'),
Navigation: path.resolve(__dirname, 'src/client/scenes/shared/navigation/index.jsx'),
Container: path.resolve(__dirname, 'src/client/scenes/Container.js')
}
},
module: {
rules: [
{
test: /\.(js|jsx)$/,
exclude: /node_modules|dist|build/,
loader: 'babel-loader',
options: {
plugins: [
[
'babel-plugin-react-css-modules',
{
context: publicPath,
filetypes: {
'.scss': 'postcss-scss'
}
}
]
]
}
},
{
test: /\.local\.(css|scss)$/,
use: [
'style-loader',
'css-loader?modules&importLoaders=1&localIdentName=[path]___[name]__[local]___[hash:base64:5]',
'postcss-loader',
'sass-loader',
{
loader: 'sass-resources-loader',
options: {
resources: [
/* uncomment for import of Bootstrap variables and mixins */
// path.resolve(__dirname, './node_modules/bootstrap/scss/_variables.scss'),
// path.resolve(__dirname, './node_modules/bootstrap/scss/_mixins.scss'),
path.resolve(__dirname, './src/client/styles/scss/variables.scss')
]
}
}
]
},
{
test: /^((?!\.local).)+\.(css|scss)$/,
use: [
'style-loader',
'css-loader',
'postcss-loader',
'sass-loader'
]
},
{
test: /\.(gif|png|jpg)$/,
/* We can specify custom publicPath if needed */
loader: 'url-loader'
}
]
},
plugins: [
/* Uncoment if you wish to write on disc instead of memory */
// new Write(),
new webpack.NamedModulesPlugin(),
new webpack.HotModuleReplacementPlugin(),
new webpack.NoEmitOnErrorsPlugin(),
new webpack.ProvidePlugin({
$: 'jquery',
jQuery: 'jquery',
jquery: 'jquery'
})
/* For Mobile and other device testing use port: 3005(external port offered by Browsersync). React-hot-reload is disabled becuase it would not work on other devices. All the changes made on client and server side will live reload on all devices. State will not be preserved. To use, uncoment this, Browsersync require at the top of the page and Access-Control-Allow-Origin inside dev-server proxy */
// new BrowserSyncPlugin({
// host: 'localhost',
// port: 3005,
// ui: {
// port: 3004
// },
// proxy: {
// target: 'http://localhost:3001/'
// },
// codeSync: true,
// open: false,
// injectChanges: false,
// reloadOnRestart: true,
// files: './src/build/bundle.js',
// watchOptions: {
// awaitWriteFinish: {
// /* if browser reloads before webpack updates the bundle file after change on the server, increase the time */
// stabilityThreshold: 1000
// }
// }
// })
]
}