-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.babel.js
94 lines (90 loc) · 2.01 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
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
import { resolve } from 'path'
import Package from './package.json'
import {
HotModuleReplacementPlugin,
NamedModulesPlugin,
EnvironmentPlugin
} from 'webpack'
import BabiliPlugin from 'babili-webpack-plugin'
import OfflinePlugin from 'offline-plugin'
import eslintOptions from './.eslintrc.json'
import {readFileSync} from 'fs'
const babelOptions = JSON.parse(readFileSync(resolve(__dirname, '.babelrc')))
const production = !/dev/i.test(`${process.argv}`)
export default {
entry: {
[`${Package.name}`]: production ? `./src/${Package.name}.lsc` : [
'react-hot-loader/patch',
`./src/${Package.name}.lsc`
]
},
output: {
path: __dirname,
filename: `${Package.name}.js`,
publicPath: '/'
},
module: {
rules: [{
test: /\.lsc$/,
use: [{
loader: 'babel-loader',
options: production ? babelOptions : {
"presets": [
["env", {
"targets": {
"chrome": 55
}
}],
"lightscript",
"stage-3"
],
"plugins": ["tcomb"]
}
}, {
loader: 'eslint-loader',
options: eslintOptions
}]
}, {
test: /\.styl/,
loaders: [
'style-loader',
'css-loader',
'stylus-loader',
'stylint-loader'
]
}]
},
resolve: {
modules: [
resolve(__dirname, 'src'),
'node_modules'
],
extensions: ['.js', '.json', '.lsc', '.styl']
},
devtool: production ? 'source-map' : 'cheap-module-eval-source-map',
context: __dirname,
target: 'web',
devServer: {
contentBase: __dirname,
hot: true
},
plugins: production ? [
new EnvironmentPlugin({
NODE_ENV: 'production',
DEBUG: false
}),
new OfflinePlugin({
externals: [
'index.html'
],
}),
new BabiliPlugin()
] : [
new EnvironmentPlugin({
NODE_ENV: 'development',
DEBUG: true
}),
new NamedModulesPlugin(),
new HotModuleReplacementPlugin()
]
}