-
Notifications
You must be signed in to change notification settings - Fork 1
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
Build Process #3
Comments
I could try to provide a basic |
We don't need a build process for themes. We just need something for our own projects. Themes can import the raw JS and SCSS files into their own build process if they want from If themes don't want to import, they can simply enqueue the production assets from Here's a basic // Import required packages.
const mix = require( 'laravel-mix' );
// Set dev path.
const devPath = 'resources';
// Set public path.
mix.setPublicPath( 'public' );
// Set options.
mix.options( {
postCss : [ require( 'postcss-preset-env' )() ],
processCssUrls : false
} );
// Source maps.
mix.sourceMaps();
// Versioning and cache-busting with `mix-manifest.json`.
mix.version();
// Compile JS.
mix.js( `${devPath}/js/customize-controls.js`, 'js' );
// Sass configuration.
var sassConfig = {
outputStyle : 'expanded',
indentType : 'tab',
indentWidth : 1
};
// Compile SASS/CSS.
mix.sass( `${devPath}/scss/customize-controls.scss`, 'css', sassConfig );
// Extra Webpack config.
mix.webpackConfig( {
stats : 'minimal',
devtool : mix.inProduction() ? false : 'source-map',
performance : { hints : false },
externals : { jquery : 'jQuery' },
} ); |
I've added the webpack example here: https://github.com/WPTRT/customize-section-button/tree/feature/add-webpack-config If it's too complicated let me know. I've changed some things (using scss and some minor modifications as well). |
I've got to admit that I'm not a fan of it, but I'm also not a fan of normal Webpack config anyway. I think it's overly complicated for the vast majority of use cases. The I added Laravel Mix in b9945de. I should've done it on a separate branch so that we could test both implementations, but I wasn't thinking. Commands are: npm run dev
npm run watch
npm run prod I also added in |
Yes, since when you build the resources it will be made with hash added to it (that's why there's My branch has the commands npm run start
npm run build And there's the precommit script that will be run by husky. And good catch about the |
Just my 2c: Another issue is that by introducing this complexity it's no longer a drop-in component. A theme author can't just drop this in their theme and be done with it, they'll have to start cleaning up, removing more than half the files in the repo just to get to a point where they can say "it's now ready to go in my theme". |
When using Composer, you should use One thing related to this discussion is that I would like to provide the |
When you put it like that it makes perfect sense 😆 |
One thing that we should probably decide early on is what system to use for building compiling assets and so on. This project has minimal CSS and JS, so we could get by without anything. But, I'd rather have a consistent method of handling this in any project that includes CSS/JS that we do.
Personally, I'm a fan of Laravel Mix simply because it's super simple to configure: https://laravel-mix.com/ But, I'm open to anything else if someone with more JS and build experience is willing to tackle setting things up.
Goals
We have two goals:
File organization
Here's how I do things in my projects:
The text was updated successfully, but these errors were encountered: