-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.babel.js
56 lines (49 loc) · 1.27 KB
/
webpack.config.babel.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
const path = require('path')
const mkpath = require('mkpath')
const fsExtra = require('fs-extra')
const isProduction = process.env.FRIG_ENV === 'production'
const entry = {}
const example = (name) => {
const relativePath = [name, name].join('/')
const htmlSrc = `./src/${name}/index.html`
const htmlDest = `./dist/${name}/index.html`
entry[relativePath] = `./src/${relativePath}.jsx`
if (!isProduction) return undefined
mkpath.sync(path.dirname(htmlDest))
return fsExtra.copySync(htmlSrc, htmlDest)
}
if (isProduction) {
example('the-basics')
} else {
example('kitchen-sink')
example('horizontal-login')
example('the-basics')
example('two-way-data-binding')
example('component-functions')
}
module.exports = {
entry,
devtool: 'inline-source-map',
output: {
path: isProduction ? './dist' : './examples',
filename: '[name].js',
},
devServer: {
contentBase: './src',
},
module: {
loaders: [
{
test: /\.jsx?$/,
loader: 'babel',
query: {
presets: ['es2015', 'react', 'stage-1'],
plugins: ['babel-plugin-transform-decorators-legacy'],
},
}, {
test: /\.woff($|\?)|\.woff2($|\?)|\.ttf($|\?)|\.eot($|\?)|\.svg($|\?)/,
loader: 'url-loader',
},
],
},
}