-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwebpack.config.js
More file actions
34 lines (32 loc) · 1.17 KB
/
Copy pathwebpack.config.js
File metadata and controls
34 lines (32 loc) · 1.17 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
let HtmlWebpackPlugin = require('html-webpack-plugin');
let path = require('path');
let fs = require('fs');
let srcpath = path.resolve('./src');
let srcDirectories = fs.readdirSync(srcpath);
let config = srcDirectories.filter(dirname => {
if (dirname === '.DS_Store') {
return false;
}
return true;
}).map(dirname => {
return {
devtool: 'cheap-eval-source-map',
entry: path.resolve(`./src/${dirname}/script.js`),
output: {
path: path.resolve(`./build/${dirname}`),
filename: `${dirname}.bundle.js`
},
module: {
loaders: [
{ test: /\.js$/, exclude: /node_modules/, loader: "babel-loader" },
{ test: /\.css$/, exclude: /node_modules/, loader: 'style-loader!css-loader' },
{ test: /\.scss$/, exclude: /node_modules/, loader: 'style-loader!css-loader!sass-loader' },
{ test: /\.txt$/, exclude: /node_modules/, loader: 'raw-loader' }
]
},
plugins: [
new HtmlWebpackPlugin({filename: 'index.html', template: path.resolve(`./src/${dirname}/index.html`)})
]
}
});
module.exports = config;