Adding Webpack v3 and Babel for ES6 Support#2
Adding Webpack v3 and Babel for ES6 Support#2greteltrost wants to merge 1 commit intoskilld-labs:8.x-7.xfrom
Conversation
|
Note: I added lodash as example, but commented it out on init.js |
| }, | ||
| devtool: 'source-map' | ||
| }; | ||
|
|
There was a problem hiding this comment.
Also related to #5, we need to handle the NODE_ENV variable here when it gets the value of production and add uglifyjs as a webpack plugin,
something like:
if (process.env.NODE_ENV === 'production') {
config.plugins.push(
new webpack.optimize.UglifyJsPlugin({
compress: {
screw_ie8: true
}
})
)
}There was a problem hiding this comment.
Updated webpack to use env variables and handle file compression.
|
Great work! I have no experience with babel. So could you provide some simple steps to check like:
Thank you ) |
|
Updated PR description to add steps for testing and some more info. Let me know if you run into any issues. |
| // Build Javascript. | ||
| // ################# | ||
| gulp.task('scripts', [], function () { | ||
| return gulp.src('js/init.js') |
There was a problem hiding this comment.
Here would be better use options.theme.js variable
| @@ -1,31 +0,0 @@ | |||
| /** | |||
There was a problem hiding this comment.
Why we need to remove script.js file?
This file will be included in libraries definition
https://github.com/skilld-labs/zen/blob/8.x-7.x/STARTERKIT/STARTERKIT.libraries.yml#L15
There was a problem hiding this comment.
it suits us better because init.js makes more sense as its the initialization file
| }, | ||
| output: { | ||
| path: __dirname + '/dist', | ||
| filename: 'app.js', |
There was a problem hiding this comment.
How we will include this file to project theme?
Maybe need to add reference to this file in libraries file below https://github.com/skilld-labs/zen/blob/8.x-7.x/STARTERKIT/STARTERKIT.libraries.yml#L15
Btw app.js name has weird semantic.
For me better will be combine/replace this file with original scripts file
There was a problem hiding this comment.
its the generated output, we add only app.js and we are done
|
Need final affection tests of es6 code to project theme. |
|
Updated require('script-loader!./behaviors.js');This way we can have the old import * from 'sidebar.js'and then webpack will parse all of them for you and you will get only one file in result (this is NOT concatenation, webpack is way more advanced than that) |
|
We still have not included js files to theme :( Before changes we have script.js file that can be included to theme after comment line https://github.com/skilld-labs/zen/blob/8.x-7.x/STARTERKIT/STARTERKIT.libraries.yml#L15 Now this file is deleted @xarturia lets add proper changes to STARTERKIT.libraries.yml |
|
Fixed bug in gulpfile and added the javascript output to the theme libraries file. |
|
thank you Gretel |
andypost
left a comment
There was a problem hiding this comment.
Codestyle issues, but adopt/exclude gulpfile from sniffers makes sense.
Maybe needs new issue to discus "buatifer" for js (compatiple with drupal.ord requirements)
| @@ -0,0 +1,3 @@ | |||
| { | |||
| "presets": ["es2015"] | |||
| } No newline at end of file | |||
| styleguide | ||
| libraries | ||
| *.map | ||
| dist No newline at end of file |
| $ = require('gulp-load-plugins')(), | ||
| browserSync = require('browser-sync').create(), | ||
| del = require('del'), | ||
| var gulp = require('gulp'), |
There was a problem hiding this comment.
This makes drupal code style checker phpcs --standard=Drupal . to fail
|
What are we waiting for here ? |
|
|
it should be ready now, some of the issues (for the gulpfile) will be solved in a separated task |
|
Updated and rebased, ready to be merged. This one is tested on several new projects so we know its safe to get it in. |
Added gulp task
scriptsand webpack is handled with this task. If everything is ok I will update README to reflect the changes.Steps to test:
1- install fresh drupal
2- clone repo (github.com/greteltrost/zen) and checkout to 'webpack' branch
3- install new theme from starterkit and enable it
4- test es6 by adding some sample code on js/init.js:
5- build js with webpack by running
gulporNODE_ENV=production gulpfor minified version (or only javascript withgulp scripts)6- check new code, should be transpiled to something that all browsers should be capable to run on /dist/app.js
More info about webpack on https://webpack.js.org/concepts/