Git Product home page Git Product logo

ben-rogerson / agency-webpack-mix-config Goto Github PK

View Code? Open in Web Editor NEW
103.0 5.0 13.0 4.28 MB

๐Ÿ‘จโ€๐Ÿ’ป A capable website/webapp boilerplate ready for the web agency battlefield. Creates a static site with Twig templating by default. Supports Craft/Wordpress/Laravel after a few adjustments.

JavaScript 86.06% CSS 6.29% HTML 6.31% Vue 1.34%
webpack-configuration laravel-mix craft-boilerplate static-site-boilerplate craft-cms static-site-generator laravel-b

agency-webpack-mix-config's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

agency-webpack-mix-config's Issues

Tailwind CSS not getting parsed (PostCSS)

This line in webpack.mix.js no longer seems to parse TailwindCSS directives (just remains as e.g.@tailwind components; in the generated CSS. This was working previously, and I I think 0be9d43 was the change that broke it.

mix.options({
    postCss: [
         require('tailwindcss')('./tailwind.config.js'),
     ],
})

Issue with using sprite.svg

@ben-rogerson I have a use-case which looks something like this:

.class{
 &:before{
  content: url("sprite.svg#icon-email");
 }
}

The email.svg is placed under icons directory. What will be a correct way to refer to SVG in SCSS?

I have also noticed that running npm run dev or npm run build will not generate sprite.svg. Not sure what could be the reason.

Expand upon Craft 3 (and other CMS) integration

Great starter kit, but I ran into some trouble integrating with Craft 3 after following the provided instructions.

When switching Mix over from static file building to CMS integration (proxy), the devServer settings should be changed to reflect this as well. e.g. if you don't add a publicPath setting, webpack reports webpack output is served from https://undefined:undefined/.

mix.webpackConfig({
    devServer: {
        clientLogLevel: "none", // Hide console feedback so eslint can take over
        open: false,
        overlay: true,
        port: config.devServerPort,
        public: `localhost:${config.devServerPort}`,
        host: "0.0.0.0", // Allows access from network
        https: config.devProxyDomain.includes("https://"),
        contentBase: config.devWatchPaths.length
            ? config.devWatchPaths
            : undefined,
        watchContentBase: config.devWatchPaths.length > 0,
        publicPath: "/", // <-- for proxy use
        ...

Another thing that needs to be set is 'useAbsoluteUrl' => false, in your config/twigpack.php settings file. If you fail to do so while trying to run the dev server (with HMR), the Twigpack plugin sets the asset path based on Craft's "Site Base" (or FQDN), creating links to assets that don't exist since HMR assets exist in-memory only.

For example, while running the dev server, opening https://localhost:8080 reveals the Craft entry page, but looking at the source, the CSS and JS paths are set to https://my-website.test/dist/main.css instead of https://localhost:8080/dist/main.css which would point to the correct in-memory path.

TLDR;
add publicPath: "/", to Mix's devServer and
'useAbsoluteUrl' => false, in config/twigpack.php

Anyway, hope this helps anyone else integrating with Craft 3.

Clarification on removing excess packages docs step

@ben-rogerson In the section removing-excess-packages it is said to remove laravel-mix-twig-to-html among two other packages. Doing so will return the following error when running npm run dev or npm run start or npm run build:

internal/modules/cjs/loader.js:775
    throw err;
    ^

Error: Cannot find module 'laravel-mix-twig-to-html'
Require stack:
- /Users/<userName>/<projectName>/webpack.mix.js
- /Users/<userName>/<projectName>/node_modules/laravel-mix/setup/webpack.config.js
- /Users/<userName>/<projectName>/node_modules/webpack-cli/bin/utils/convert-argv.js
- /Users/<userName>/<projectName>/node_modules/webpack-dev-server/bin/webpack-dev-server.js
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:772:15)
    at Function.Module._load (internal/modules/cjs/loader.js:677:27)
    at Module.require (internal/modules/cjs/loader.js:830:19)
    at require (internal/modules/cjs/helpers.js:68:18)
    at Object.<anonymous> (/Users/<userName>/<projectName>/webpack.mix.js:79:1)
    at Module._compile (internal/modules/cjs/loader.js:936:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:947:10)
    at Module.load (internal/modules/cjs/loader.js:790:32)
    at Function.Module._load (internal/modules/cjs/loader.js:703:12)
    at Module.require (internal/modules/cjs/loader.js:830:19)
    at require (internal/modules/cjs/helpers.js:68:18)
    at Object.<anonymous> (/Users/<userName>/<projectName>/node_modules/laravel-mix/setup/webpack.config.js:12:1)
    at Module._compile (internal/modules/cjs/loader.js:936:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:947:10)
    at Module.load (internal/modules/cjs/loader.js:790:32)
    at Function.Module._load (internal/modules/cjs/loader.js:703:12) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    '/Users/<userName>/<projectName>/webpack.mix.js',
    '/Users/<userName>/<projectName>/node_modules/laravel-mix/setup/webpack.config.js',
    '/Users/<userName>/<projectName>/node_modules/webpack-cli/bin/utils/convert-argv.js',
    '/Users/<userName>/<projectName>/node_modules/webpack-dev-server/bin/webpack-dev-server.js'
  ]
}

Perhaps the docs can be edited to reflect that.

Thanks

Images folder shouldn't be flattened

The images in source (src/images) are dropped into the dist folder with all sub folders flattened. This causes issues if there are images with the same file name, and is a hassle if you want to use sub folders.

Can be easily changed by replacing line 272 of webpack.mix.js with context: "src".

Edit: typo and formatting

Webpack clean plugin issues

This plugin seems to fire at the wrong time in certain situations.
It's more solid to use rimraf to remove the built directory before we start

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.