-
Notifications
You must be signed in to change notification settings - Fork 1
/
webpack.config.js
146 lines (123 loc) · 4.77 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
var path = require('path');
var CopyWebpackPlugin = require('copy-webpack-plugin');
var TsConfigPathsPlugin = require('awesome-typescript-loader').TsConfigPathsPlugin;
var BitBarWebpackProgressPlugin = require("bitbar-webpack-progress-plugin");
const ExtractTextPlugin = require("extract-text-webpack-plugin");
const CommonsChunkPlugin = require("webpack/lib/optimize/CommonsChunkPlugin")
const VueLoaderPlugin = require('vue-loader/lib/plugin')
const extractLess = new ExtractTextPlugin({
filename: "styles.css",
// might want to use style-loader for development?
// it lets you hot-reload styles? If so, this next commented line prevents styles.css from getting built statically.
// disable: process.env.NODE_ENV === "development"
});
function isExternal(module) {
var context = module.context;
if (typeof context !== 'string') {
return false;
}
return context.indexOf('node_modules') !== -1;
}
module.exports = {
entry: {
scripts: "./src/Main.js",
styles: "./src/styles/styles.less",
},
output: {
path: path.resolve(__dirname, "./buildbot_react_plugin_boilerplate/static"),
filename: "[name].js"
},
plugins: [
// Separate "vendors" bundle for external libraries?
// new CommonsChunkPlugin({
// name: 'vendors',
// minChunks: function(module) {
// return isExternal(module);
// }
// }),
// might want to add something like this for copying assets like images, but to where?
// new CopyWebpackPlugin([
// // Copy over React and any other node modules which are not being bundled by webpack.
// // (we avoid bundling them to enable browser caching and decrease reload times.)
// { from: 'assets', to: 'build/static/assets'},
// ]),
new BitBarWebpackProgressPlugin(),
new VueLoaderPlugin(),
extractLess
],
// Enable sourcemaps for debugging webpack's output.
devtool: "source-map",
resolve: {
// Add '.ts' and '.tsx' as resolvable extensions.
extensions: [".ts", ".tsx", ".js", ".vue"],
plugins: [
new TsConfigPathsPlugin(/* { tsconfig, compiler } */),
],
alias: {
'vue$': 'vue/dist/vue.esm.js' // 'vue/dist/vue.common.js' for webpack 1
}
},
module: {
rules: [
// all files ending with ".vue" are loaded using vue-loader
{ test: /\.vue$/, loader: 'vue-loader' },
{
// JS LOADER
// Reference: https://github.com/babel/babel-loader
// Transpile .js files using babel-loader
// Compiles ES6 and ES7 into ES5 code
test: /\.js$/,
loader: 'babel-loader',
exclude: /node_modules/
},
// All files with a '.ts' or '.tsx' extension will be handled by 'ts-loader' or awesome-typescript-loader'.
{ test: /\.tsx?$/, loader: "awesome-typescript-loader" },
// All output '.js' files will have any sourcemaps re-processed by 'source-map-loader'.
{
enforce: "pre",
test: /\.js$/,
loader: "source-map-loader",
},
{
test: /\.css$/,
use: [
'vue-style-loader',
'css-loader'
]
},
{
test: /\.less$/,
use: extractLess.extract({
use: [{
loader: "css-loader"
}, {
loader: "less-loader"
}],
// use style-loader in development
fallback: "style-loader"
})
}
// {
// test: /.(png|jpg|jpeg|gif|svg|woff|woff2|ttf|eot)$/,
// //use: "url-loader?limit=100000"
// use: [ {
// loader: "file-loader",
// options: {
// outputPath: "build/static/assets/"
// }
// }]
// }
],
},
// When importing a module whose path matches one of the following, just
// assume a corresponding global variable exists and use that instead.
// This is important because it allows us to avoid bundling all of our
// dependencies, which allows browsers to cache those libraries between builds.
// externals: {
// "react": "React",
// "react-dom": "ReactDOM"
// },
// node: {
// fs: "empty"
// },
};