-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
98 lines (90 loc) · 2.88 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
// Webpack configuration for the jigs CLI tool.
const path = require('path')
const Webpack = require('webpack')
const nodeExternals = require('webpack-node-externals')
const __DEV__ = process.env.NODE_ENV !== 'production'
const __PROD__ = !__DEV__
let config = {
mode: __DEV__ ? 'development' : 'production',
entry: {
index: './index.js',
'jigs-page-loader': './lib/builder/jigs-build-webpack/page-loader',
'jigs-page-post': './lib/builder/jigs-build-webpack/page-post'
},
optimization: {
// Don't replace process.env.NODE_ENV with Webpack's mode.
// Want jigs to be able to set it as it sees fit, regardless of how the
// bundle was built by Webpack.
nodeEnv: false,
},
output: {
publicPath: '/',
path: path.resolve(__dirname, './build'),
filename: '[name].js',
libraryTarget: 'commonjs2'
},
devtool: 'cheap-source-map',
module: {
// Ignore this file...
noParse: /unbundledRequire/,
rules: [
{
test: /\.js$/,
enforce: 'pre',
exclude: /node_modules/,
use: {
loader: 'eslint-loader',
options: {
emitError: true,
failOnError: true,
failOnWarning: true,
// TODO: use in dev only?
emitWarning: true,
// speed up full build by caching linting results
// NOTE: using the cache when doing a full build causes mess-ups
// when editing the .eslintrc file because the rules change but the
// old cache from the old ruleset is used
cache: __DEV__,
// a user-friendly eslint output formatter for the terminal
formatter: require('eslint-formatter-friendly'),
// TODO: for some reason eslint wasn't finding the config file
// NOTE: this disables "local" eslint files in directories with
// source code
configFile: path.resolve(__dirname, '.eslintrc.js')
}
}
},
{
test: /\.js$/,
exclude: /node_modules/,
use: {
loader: 'babel-loader',
}
// see .babelrc for options
}
]
},
target: 'node',
node: {
__dirname: false
},
externals: [nodeExternals()], // in order to ignore all modules in node_modules folder
plugins: [
// TODO:
// NoErrorsPlugin
//
// NoErrorsPlugin prevents webpack from outputting anything into a bundle.
// So even ESLint warnings will fail the build. No matter what error
// settings are used for eslint-loader. So if you want to see ESLint
// warnings in console during development using WebpackDevServer remove
// NoErrorsPlugin from webpack config.
// skips all emitting (outputting) when there are errors.
new Webpack.NoEmitOnErrorsPlugin()
]
}
if (__DEV__) {
config.plugins.push(new Webpack.LoaderOptionsPlugin({
debug: true
}))
}
module.exports = config