-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
executable file
·62 lines (59 loc) · 1.75 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
var webpack = require("webpack");
var path = require("path");
const merge = require('webpack-merge');
const DotenvPlugin = require('webpack-dotenv-plugin');
const common = {
// entry point of our application
entry: ['./main.js'],
// where to place the compiled bundle
output: {
path: __dirname,
filename: 'build.js'
},
resolve: {
extensions: ['', '.js', '.vue']
},
module: {
// `loaders` is an array of loaders to use.
// here we are only configuring vue-loader
loaders: [{
test: /\.vue$/, // a regex for matching all files that end in `.vue`
loader: 'vue', // loader to use for matched files
exclude: /node_modules/
}, {
test: /\.scss$/,
loaders: ["style", "css", "sass"]
}, {
// use babel-loader for *.js files
test: /\.js$/,
loader: 'babel',
// important: exclude files in node_modules
// otherwise it's going to be really slow!
exclude: /node_modules/
}]
},
// if you are using babel-loader directly then
// the babel config block becomes required.
babel: {
presets: ['es2015'],
plugins: ['transform-runtime']
}
};
var config;
// Detect how npm is run and branch based on that
switch (process.env.npm_lifecycle_event) {
case 'test':
/* We want to use a different env file for testing */
config = merge(common, {
plugins: [new DotenvPlugin({
sample: './.env.default',
path: './.env.test'
})]
});
break;
default:
config = merge(common, {
plugins: [new DotenvPlugin()]
});
}
module.exports = config;