frontend_app_workspace_advanced/webpack.config.js   A
last analyzed

Complexity

Total Complexity 6
Complexity/F 0

Size

Lines of Code 88
Function Count 0

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 6
wmc 6
eloc 61
nc 64
mnd 1
bc 0
fnc 0
dl 0
loc 88
rs 10
bpm 0
cpm 0
noi 1
c 0
b 0
f 0
1
const webpack = require('webpack')
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
2
const path = require('path')
3
const isProduction = process.env.NODE_ENV === 'production'
4
5
console.log('isProduction : ', isProduction)
0 ignored issues
show
Debugging Code introduced by
console.log looks like debug code. Are you sure you do not want to remove it?
Loading history...
6
7
module.exports = {
8
  entry: isProduction
9
    ? './src/index.js' // only one instance of babel-polyfill is allowed
10
    : ['babel-polyfill', './src/index.dev.js'],
11
  output: {
12
    path: path.resolve(__dirname, 'dist'),
13
    filename: isProduction ? 'workspace_advanced.app.js' : 'workspace_advanced.app.dev.js',
14
    pathinfo: !isProduction,
15
    library: isProduction ? 'appWorkspaceAdvanced' : undefined,
16
    libraryTarget: isProduction ? 'var' : undefined
17
  },
18
  externals: {},
19
  // isProduction ? { // Côme - since plugins are imported through <script>, cannot externalize libraries
20
  //   react: {commonjs: 'react', commonjs2: 'react', amd: 'react', root: '_'},
21
  //   'react-dom': {commonjs: 'react-dom', commonjs2: 'react-dom', amd: 'react-dom', root: '_'},
22
  //   classnames: {commonjs: 'classnames', commonjs2: 'classnames', amd: 'classnames', root: '_'},
23
  //   'prop-types': {commonjs: 'prop-types', commonjs2: 'prop-types', amd: 'prop-types', root: '_'},
24
  //   tracim_lib: {commonjs: 'tracim_lib', commonjs2: 'tracim_lib', amd: 'tracim_lib', root: '_'}
25
  // }
26
  // : {},
27
  devServer: {
28
    contentBase: path.join(__dirname, 'dist/'),
29
    host: '0.0.0.0',
30
    port: 8076,
31
    hot: true,
32
    noInfo: true,
33
    overlay: {
34
      warnings: false,
35
      errors: true
36
    },
37
    historyApiFallback: true
38
    // headers: {
39
    //   'Access-Control-Allow-Origin': '*'
40
    // }
41
  },
42
  devtool: isProduction ? false : 'cheap-module-source-map',
43
  module: {
44
    rules: [{
45
      test: /\.jsx?$/,
46
      enforce: 'pre',
47
      use: 'standard-loader',
48
      exclude: [/node_modules/]
49
    }, {
50
      test: [/\.js$/, /\.jsx$/],
51
      loader: 'babel-loader',
52
      options: {
53
        presets: ['env', 'react'],
54
        plugins: ['transform-object-rest-spread', 'transform-class-properties', 'transform-object-assign']
55
      },
56
      exclude: [/node_modules/]
57
    }, {
58
      test: /\.css$/,
59
      use: ['style-loader', 'css-loader']
60
    }, {
61
      test: /\.styl$/,
62
      use: ['style-loader', 'css-loader', 'stylus-loader']
63
    }, {
64
      test: /\.(jpg|png|svg)$/,
65
      loader: 'url-loader',
66
      options: {
67
        limit: 25000
68
      }
69
    }]
70
  },
71
  resolve: {
72
    extensions: ['.js', '.jsx']
73
  },
74
  plugins: [
75
    ...[], // generic plugins always present
76
    ...(isProduction
77
      ? [ // production specific plugins
78
        new webpack.DefinePlugin({
79
          'process.env': { 'NODE_ENV': JSON.stringify('production') }
80
        }),
81
        new webpack.optimize.UglifyJsPlugin({
82
          compress: { warnings: false }
83
        })
84
      ]
85
      : [] // development specific plugins
86
    )
87
  ]
88
}
89