morlay / babel-plugin-transform-require-ignore

65 stars 13 forks source link

ignoring at client side as well #3

Closed abhijeetNmishra closed 7 years ago

abhijeetNmishra commented 7 years ago

I have my npm start script as below = BABEL_ENV='node' babel-node --debug server/bin/boot.js

and babelrc file

{
  "presets": ["es2015", "react"],
  "ignore": ["server"],
  "env": {
    "node": {
      "plugins": [
        ["babel-plugin-transform-require-ignore", {
          "extensions": [".css"]
        }]
      ]
    }
  }
}

webpack config

{
  test: /\.js$/,
  exclude: /node_modules/,
  include: base.paths.client,
  use: ['babel-loader'],
  options: {
    presets: ['es2015', 'react', {
      modules: false
    }],
    ignore: [base.paths.server]
  }
}, {
  test: /\.css$/,
  loader: ExtractTextPlugin.extract({
    fallbackLoader: 'style-loader',
    loader: 'css-loader'
  }
webpack --config webpack.config.js

generates both main.js and main.css files but npm start only creates main.js

Any idea ?

morlay commented 7 years ago

It is because of babel-loader. For now, babelrc of https://github.com/babel/babel-loader#options is default true, which will merge babel configuration in babelrc. You should disable it by babelrc: false.