videojs-chapter-thumbnails icon indicating copy to clipboard operation
videojs-chapter-thumbnails copied to clipboard

chore(webpack) only apply transform-runtime to prod build

Open justinanastos opened this issue 8 years ago • 5 comments

This will allow this package to npm-link'ed by not using transform-runtime unless we're building production.

justinanastos avatar Apr 14 '17 14:04 justinanastos

@justinanastos looks interesting—did this implementation come from an article?

also,

what is the difference between that implementation and the following:

process.env.BABEL_ENV = 'production';
process.env.NODE_ENV = 'production';

or

new webpack.DefinePlugin({
  'process.env.NODE_ENV': JSON.stringify('production'),
})

chemoish avatar Apr 14 '17 20:04 chemoish

@chemoish This did not come from an article. When trying to npm link this package, there was an issue with transform-runtime. Since that's only needed for prod, this will only use it on prod.

  • I didn't want to require environmental variables be set to make this work.
  • webpack.DefinePlugin() will define things for the transpiled source, it won't set the env for .babelrc (I think)

This solution comes from the babel-loader docs to just set the local environment regardless of NODE_ENV or BABEL_ENV. [email protected]#options

justinanastos avatar Apr 14 '17 20:04 justinanastos

I got the idea to test removing transform-runtime from this post https://stackoverflow.com/questions/36313885/babel-6-transform-runtime-export-is-not-a-function

justinanastos avatar Apr 14 '17 20:04 justinanastos

BABEL_ENV=production webpack --config webpack/webpack.config.production?

is the workflow to manually run npm run build after changes? or are you also trying to leverage npm start?

chemoish avatar Apr 14 '17 21:04 chemoish

I was just using the source and not the built file.

justinanastos avatar Apr 18 '17 16:04 justinanastos