-
Notifications
You must be signed in to change notification settings - Fork 21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add new webpack config #105
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sweet! I've left some questions, mainly as I don't know much about webpack-blocks
const BabiliPlugin = require('babili-webpack-plugin'); | ||
const path = require('path'); | ||
|
||
const babelConfig = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
with babelConfig
you mean babel-loader config?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, but it will be shared with typescript
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what will be shared the babel config or the babel-loader config? as in there there are things that are pure babel-loader for webpack related as cacheDirectory: true
. Perhpash we can make this more evident and with better naming of what get shared and what not? Otherwise I think we'll be sharing with ts stuff that he doesn't need/support and I'll rather avoid that
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Have removed the loader specific bit, as babel would complain
const HtmlWebpackPlugin = require('html-webpack-plugin'); | ||
const ProgressBarPlugin = require('progress-bar-webpack-plugin'); | ||
const CopyWebpackPlugin = require('copy-webpack-plugin'); | ||
const BabiliPlugin = require('babili-webpack-plugin'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we use uglify, do we need babili?
const autoprefixer = require('autoprefixer'); | ||
const webpack = require('webpack'); | ||
const HtmlWebpackPlugin = require('html-webpack-plugin'); | ||
const ProgressBarPlugin = require('progress-bar-webpack-plugin'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do we need the progress bar for?
entryPoint(path.join(process.cwd(), 'src', 'index' + ending)), | ||
setOutput(path.join(process.cwd(), 'build', 'bundle.[hash].js')), | ||
babel(), | ||
sass(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we leave css related configs to a later PR where we just deal with that ? (saas, autoprefixer,..)
module.exports = function(language) { | ||
const ending = language === 'javascript' ? 'js' : 'ts' | ||
const baseConfig = [ | ||
entryPoint(path.join(process.cwd(), 'src', 'index' + ending)), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we really need blocks for those? Not sure I see the whole benefits for entryPoint
and setOutput
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for consitency, I would say yes
setOutput(path.join(process.cwd(), 'build', 'bundle.[hash].js')), | ||
babel(), | ||
sass(), | ||
extractText('[name].[contenthash].css', 'text/x-sass'), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is this for?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
extract the css out of the webpack bundle
]), | ||
env('development', [ | ||
devServer({}, require.resolve('react-dev-utils/webpackHotDevClient')), | ||
sourceMaps() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what is the sourceMaps default?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cheap-module-source-map
never had issues with them
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cool, yes that's the one I also use them, just wanted to learn about its preset. We should comment those things above them, I think will be super valuable for people that don't know blocks
]), | ||
env('production', [ | ||
addPlugins([ | ||
new webpack.optimize.UglifyJsPlugin(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess we want Uglify to also work with maps as per our sourcemaps settings perhaps?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are source maps needed in production? Currently I only added them in the dev
environment
// https://github.com/vuejs/vue-loader/issues/666 | ||
process.noDeprecation = true | ||
|
||
const { createConfig, defineConstants, env, entryPoint, setOutput, sourceMaps, addPlugins } = require('@webpack-blocks/webpack2'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Destructuring assignments are not fully supported in node4. I guess we want to keep support to both 4 and 6 for the moment?
I think you also want to add the dependency to the cycle-scripts package.json :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice. I think this part is pretty clean now
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure seing the release speed of webpack-blocks especially in relation to their dependencies that is something we should go with..
@@ -30,12 +30,16 @@ | |||
"cycle-scripts": "./index.js" | |||
}, | |||
"dependencies": { | |||
"babel-core": "^6.24.1", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wow webpack-blocks runs on 6.17.0 of babel-core and 6.2.5 of babel-loader. I knew this wasn't a good idea... :(.
Also seems that updating is not something done on a regular base...just 3 release...my bad I didn't check this earlier
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will still install and use the newest version though
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You mean if we keep that dependency? Is that something we really wanna do then?
Tbh, now that I see how it works, is not such a big deal achieve the same thing without block, as mainly is env, devserver, and different plugins for typescrpt. I think you can achieve this easily within a plain webpack config object. What make you so vocal about this? I'm probably missing something as I cannot see such an added value, apart of taking ownership of important dependencies like loaders&co away from you...i must be wrong though...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no, because ^6.24.1
will match every minor and patch update. So the dependencies of the blocks are automaticly kept up to date, unless there is a new major version
This is what npm update
is for
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A change in the package.json is only for indicating that the update is tested.
Maybe one day Greenkeeper will have monorepo support, then it can be also added to the package.json
But it's not really needed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, but if something cause an issue with a specific vers we cannot lock for example babel-core... anyway. Good job. I'll review the rest later
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I very much look forward to that day of greenkeeper supporting nested packages :)
I see this still in WIP, I've reviewed everything and so far so good to me! |
Yes, was busy finishing my talk :). Will work on it later |
tested it, everything works now |
Should we make the tsconfig part of the template or not?
Im currently in favor of the third option I would set the following flags (as default for option 1 and 3)
|
I removed tslint to be included in the linting PR |
I would leave the questions to remove From my side this PR is done, please have another look @nickbalestra |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My general feeling is that at the end to support both TS and JS + streamLibs we need to do quite few compromise and the whole flavor get slightly over complex compared to having two separate flavors, perhaps with some code duplication, but totally independent in how they can evolve and improve over time, what you think?
@@ -1,4 +1,4 @@ | |||
'use strict' | |||
module.exports = language => `'use strict' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I get this right, this is not a configuration file for webpack anymore, but a precompiled template that will compile to a webpack configuration factory? If so filename is perhaps misleading, no?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i can rename it to webpack.config.template.js
start: 'node scripts/start.js', | ||
test: 'node scripts/test.js', | ||
build: 'node scripts/build.js' | ||
start: 'NODE_ENV=development webpack-dev-server --config webpack.config.js', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So eject users at the end will get a plain webpack config...? 😛
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, no traces of the flavor
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No sure we did discussed about this, or I missed this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not sure, but at least I dont want any external scripts in my git
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think that this is the right approach we should use for putting things into PR and deciding what should be a feature and what's not, there are issue to discuss this...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok, i will add them back in and make a different PR
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
see #107
test: 'node scripts/test.js', | ||
build: 'node scripts/build.js' | ||
start: 'NODE_ENV=development webpack-dev-server --config webpack.config.js', | ||
build: 'NODE_ENV=production webpack --config webpack.config.js' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will lead to a different experience, no? ie: no more measureFileSizesBeforeBuild
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can look into creating/searching for a webpack plugin for this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
see #107
what abou the tsconfig? |
First of all, thank you a lot for the time you putting in there, I truly appreciated! But I think is important to make few considerations before more work gets done in this directions.
Because of this I suggest we do the following:
As a first thing in this direction probably CCA could simply prompt user for streamLib only and pass that info to flavors, core and non-core. |
I did not think this is an issue, I thought eject means leave completely. Anyway I created #107 for this. I also meant that I (as user) would not want random scripts in my git, not me personally. I dont think we have to revert anything, we would not win anything. The eject works as expected and has now the cycle scripts were they were before. The only thing I need to know is if we should provide weak or strong defaults for the typescript config, then this is ready for publish. Currently we have the config hidden with weak defaults. I would make the defaults stronger, as they help to prevent run time issues. The other option would be to just copy it to the app dir and let the user change the defaults |
We are doing to many things at once. For now:
This will mark the diversity release. As we saw, having TS and JS together imply making some compromise (from smaller to bigger ones). I think all of those should be properly discussed and evaluated on specific issues, but I think we should first bring cycle-scripts (core flavor) up to date, before deciding to have a language prompt in the core flavor, That was a too early decision without having yet reached diversity and proper DX on the core cycle-scripts. After diversity release Focusing on cycle-scripts priorities:
|
This resolves #103
TODO:
webpack-blocks
based configtsconfig.json