-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathwebpack.config.js
101 lines (93 loc) · 2.73 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
const { join, resolve, relative } = require('path')
const webpack = require('webpack');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const CheckerPlugin = require('awesome-typescript-loader').CheckerPlugin;
const UglifyJsPlugin = require("uglifyjs-webpack-plugin");
const ASSET_PATH = process.env.ASSET_PATH || 'http://dev.siggy.borkedlabs.com:8083';
const extractCSS = new ExtractTextPlugin({
filename: 'site.css',
allChunks: true
});
module.exports = {
stats: { modules: false },
entry: {
'bundle': join(__dirname, 'frontend', 'Siggy.ts'),
},
output: {
path: join(__dirname, 'public','assets'),
filename: 'siggy.js',
publicPath: ASSET_PATH,
// Bundle absolute resource paths in the source-map,
// so VSCode can match the source file.
devtoolModuleFilenameTemplate: '[absolute-resource-path]',
libraryTarget: 'var',
library: 'Siggy'
},
resolve: {
extensions: ['.ts', '.tsx', '.js', '.jsx'],
modules: [resolve(__dirname, 'frontend'), 'node_modules']
},
module: {
rules: [
{ test: /\.(tsx?|jsx?)$/, include: /frontend/, use: 'awesome-typescript-loader', exclude: /vendor/ },
{
test: /\.(png|jpg|jpeg|gif|woff|woff2|eot|ttf|svg)(\?|$)/,
exclude: /vendor/,
use: 'url-loader?limit=100'
},
{
test: /\.(scss|css)$/,
exclude: /vendor/,
use: extractCSS.extract({
fallback: 'style-loader',
//resolve-url-loader may be chained before sass-loader if necessary
use: ['css-loader', 'sass-loader']
})
},
{
test: require.resolve('jquery'),
exclude: /vendor/,
use: [{
loader: 'expose-loader',
options: 'jQuery'
},{
loader: 'expose-loader',
options: '$'
}]
}
]
},
plugins: [
new webpack.DllReferencePlugin({
context: __dirname,
manifest: require('./public/assets/vendor-manifest.json')
}),
new webpack.DefinePlugin({
'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV || 'development'),
}),
new CheckerPlugin(),
extractCSS,
new webpack.SourceMapDevToolPlugin({
filename: '[file].map', // Remove this line if you prefer inline source maps
moduleFilenameTemplate: relative('./public/assets/', '[resourcePath]') // Point sourcemap entries to the original file locations on disk
})
].concat(process.env.NODE_ENV === 'production' ? [
//production
new UglifyJsPlugin({sourceMap: true})
] : [
//development
]),
devServer: {
public: 'dev.siggy.borkedlabs.com:8083',
port: 8083,
historyApiFallback: {
index: 'index.html'
},
contentBase: 'public/assets',
headers: {
"Access-Control-Allow-Origin": "*",
"Access-Control-Allow-Methods": "GET, POST, PUT, DELETE, PATCH, OPTIONS",
"Access-Control-Allow-Headers": "X-Requested-With, content-type, Authorization"
}
}
}