Last active
May 12, 2019 17:39
-
-
Save DanLaufer/e1d800c9edcc43daadede379fc455fa1 to your computer and use it in GitHub Desktop.
Laravel-Mix (webpack) drupal theme setup
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "my_site", | |
"version": "1.0.0", | |
"description": "My Site", | |
"main": "index.js", | |
"scripts": { | |
"dev": "NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js", | |
"development": "NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js", | |
"watch": "NODE_ENV=development node_modules/webpack/bin/webpack.js --watch --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js", | |
"hot": "NODE_ENV=development webpack-dev-server --inline --hot --config=node_modules/laravel-mix/setup/webpack.config.js", | |
"prod": "NODE_ENV=production node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js", | |
"production": "NODE_ENV=production node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js" | |
}, | |
"author": "", | |
"license": "ISC", | |
"devDependencies": { | |
"@ayctor/laravel-mix-svg-sprite": "github:superbiche/laravel-mix-svg-sprite", | |
"browser-sync": "^2.26.3", | |
"browser-sync-webpack-plugin": "^2.2.2", | |
"laravel-mix": "^2.1.14", | |
"svg-spritemap-webpack-plugin": "^1.2.0" | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let mix = require('laravel-mix'); | |
const BrowserSyncPlugin = require('browser-sync-webpack-plugin'); | |
// info on browsersync with mix: https://ashokgelal.com/2017/01/29/laravel-mix-browsersync/ | |
require('@ayctor/laravel-mix-svg-sprite'); | |
// info on laravel-mix-svg-sprite: https://github.com/Ayctor/laravel-mix-svg-sprite | |
// if this breaks, need to add `@^1.0.0` to line 25 of node_modules/@ayctor/laravel-mix-svg-sprite | |
// and it'll look like this: `return ['svg-spritemap-webpack-plugin@^1.0.0'];` | |
if(process.env.NODE_ENV == 'development') { | |
// DEVELOPMENT | |
mix .js('scripts/**/*.js', 'public/js/bundle.js') | |
.sass('scss/style.scss', 'public/css/style.css') | |
.svgSprite('images/svg/**/*.svg','public/images/sprite-ui.svg') | |
.options({ processCssUrls: false }) | |
.webpackConfig({ | |
plugins: [ | |
new BrowserSyncPlugin({ | |
// BrowserSync override options here: https://browsersync.io/docs/options | |
open: 'external', | |
host: 'mysite.lndo.site', | |
proxy: 'mysite.lndo.site' | |
// files: ['resources/views/**/*.php', 'app/**/*.php', 'routes/**/*.php'] | |
}) | |
] | |
}); | |
} else { | |
// PRODUCTION | |
mix .js('scripts/**/*.js', 'public/js/bundle.min.js') | |
.sass('scss/style.scss', 'public/css/style.min.css') | |
.svgSprite('images/svg/**/*.svg','public/images/sprite-ui.svg') | |
.options({ processCssUrls: false }) | |
.sourceMaps(); | |
} | |
// Full API | |
// docs: https://laravel.com/docs/5.7/mix | |
// | |
// mix.js(src, output); | |
// mix.react(src, output); <-- Identical to mix.js(), but registers React Babel compilation. | |
// mix.preact(src, output); <-- Identical to mix.js(), but registers Preact compilation. | |
// mix.coffee(src, output); <-- Identical to mix.js(), but registers CoffeeScript compilation. | |
// mix.ts(src, output); <-- TypeScript support. Requires tsconfig.json to exist in the same folder as webpack.mix.js | |
// mix.extract(vendorLibs); | |
// mix.sass(src, output); | |
// mix.standaloneSass('src', output); <-- Faster, but isolated from Webpack. | |
// mix.fastSass('src', output); <-- Alias for mix.standaloneSass(). | |
// mix.less(src, output); | |
// mix.stylus(src, output); | |
// mix.postCss(src, output, [require('postcss-some-plugin')()]); | |
// mix.browserSync('my-site.test'); | |
// mix.combine(files, destination); | |
// mix.babel(files, destination); <-- Identical to mix.combine(), but also includes Babel compilation. | |
// mix.copy(from, to); | |
// mix.copyDirectory(fromDir, toDir); | |
// mix.minify(file); | |
// mix.sourceMaps(); // Enable sourcemaps | |
// mix.version(); // Enable versioning. | |
// mix.disableNotifications(); | |
// mix.setPublicPath('path/to/public'); | |
// mix.setResourceRoot('prefix/for/resource/locators'); | |
// mix.autoload({}); <-- Will be passed to Webpack's ProvidePlugin. | |
// mix.webpackConfig({}); <-- Override webpack.config.js, without editing the file directly. | |
// mix.babelConfig({}); <-- Merge extra Babel configuration (plugins, etc.) with Mix's default. | |
// mix.then(function () {}) <-- Will be triggered each time Webpack finishes building. | |
// mix.extend(name, handler) <-- Extend Mix's API with your own components. | |
// mix.options({ | |
// extractVueStyles: false, // Extract .vue component styling to file, rather than inline. | |
// globalVueStyles: file, // Variables file to be imported in every component. | |
// processCssUrls: true, // Process/optimize relative stylesheet url()'s. Set to false, if you don't want them touched. | |
// purifyCss: false, // Remove unused CSS selectors. | |
// uglify: {}, // Uglify-specific options. https://webpack.github.io/docs/list-of-plugins.html#uglifyjsplugin | |
// postCss: [] // Post-CSS options: https://github.com/postcss/postcss/blob/master/docs/plugins.md | |
// }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment