Switch from Laravel Mix to Webpack Encore

- Updated npm dependencies
- Replaced `webpack.mix.js` with `webpack.config.js`
- Added `postcss.config.js`
- Removed the `src` directory and moved `css` and `js` to the root level
  of the theme
- Renamed `dist` to `build` and updated in libraries file

References #41
This commit is contained in:
Oliver Davies 2020-06-10 12:03:39 +01:00
parent e4da12188e
commit d343b4cdf2
22 changed files with 4880 additions and 6269 deletions

View file

@ -1,6 +1,5 @@
/*.log /*.log
/mix-manifest.json
/node_modules/ /node_modules/
# Ignore compiled assets. # Ignore compiled assets.
# /dist/ /build/

View file

@ -1,3 +1,4 @@
import '../css/tailwind.pcss'
import 'alpinejs' import 'alpinejs'
import hljs from 'highlightjs' import hljs from 'highlightjs'

View file

@ -1,11 +1,11 @@
global-styling: global-styling:
css: css:
base: base:
dist/tailwind.css: {} build/app.css: {}
global-scripts: global-scripts:
js: js:
dist/js/app.js: {} build/app.js: {}
twitter: twitter:
js: js:

File diff suppressed because it is too large Load diff

View file

@ -1,23 +1,18 @@
{ {
"private": true, "private": true,
"scripts": { "scripts": {
"build": "npm run dev", "dev": "encore dev",
"dev": "cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js", "prod": "NODE_ENV=production encore production",
"development": "npm run dev", "watch": "encore dev --watch"
"prod": "npm run production",
"production": "cross-env NODE_ENV=production node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js",
"watch": "cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --watch --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js"
}, },
"devDependencies": { "devDependencies": {
"autoprefixer": "^9.7.6", "@symfony/webpack-encore": "^0.30.2",
"cross-env": "^5.2.0", "alpinejs": "^2.3.5",
"autoprefixer": "^9.8.0",
"highlightjs": "^9.16.2", "highlightjs": "^9.16.2",
"laravel-mix": "^2.1.14",
"postcss-import": "^12.0.1", "postcss-import": "^12.0.1",
"postcss-loader": "^3.0.0",
"postcss-nested": "^4.2.1", "postcss-nested": "^4.2.1",
"tailwindcss": "^1.0.1" "tailwindcss": "^1.4.6"
},
"dependencies": {
"alpinejs": "^2.3.5"
} }
} }

View file

@ -0,0 +1,8 @@
module.exports = {
plugins: [
require('postcss-import'),
require('tailwindcss'),
require('postcss-nested'),
require('autoprefixer')
]
}

View file

@ -0,0 +1,17 @@
let Encore = require('@symfony/webpack-encore')
Encore
.disableSingleRuntimeChunk()
.cleanupOutputBeforeBuild()
.setOutputPath('build/')
.setPublicPath('/themes/custom/opdavies/build')
.addEntry('app', './js/app.js')
.enablePostCssLoader()
if (!Encore.isProduction()) {
Encore.enableSourceMaps()
}
module.exports = Encore.getWebpackConfig()

View file

@ -1,10 +0,0 @@
let mix = require('laravel-mix');
mix.postCss('src/tailwind.pcss', 'dist', [
require('postcss-import'),
require('tailwindcss'),
require('postcss-nested'),
require('autoprefixer')
])
mix.js('src/app.js', 'dist/js')