Docker throwing postcss error on sapper image build - css

I am trying to use sapper with tailwind wrapped in a docker container. When I try to build the image, docker throws this error:
The build doesn't fail but the css doesn't load correctly when running the app in the container. Nothing is wrong in the dev build and all css loads fine.
Dockerfile:
# This stage builds the sapper application.
FROM mhart/alpine-node:12 AS build-app
WORKDIR /app
COPY . .
RUN npm install --no-audit --unsafe-perm
RUN npm run build
# This stage installs the runtime dependencies.
FROM mhart/alpine-node:12 AS build-runtime
WORKDIR /app
COPY package.json package-lock.json ./
RUN npm ci --production --unsafe-perm
# This stage only needs the compiled Sapper application
# and the runtime dependencies.
FROM mhart/alpine-node:slim-12
WORKDIR /app
COPY --from=build-app /app/__sapper__ ./__sapper__
COPY --from=build-app /app/static ./static
COPY --from=build-runtime /app/node_modules ./node_modules
ENV PORT 8080
ENV HOST 0.0.0.0
EXPOSE 8080
CMD ["node", "__sapper__/build"]
Package.json:
"watch:tailwind": "postcss static/tailwind.css -o static/index.css -w",
"build:tailwind": "NODE_ENV=production postcss static/tailwind.css -o static/index.css",
"build": "npm run build:tailwind && sapper build --legacy",
"dev": "sapper dev",
"export": "sapper export --legacy",
"start": "node __sapper__/build",
"cy:run": "cypress run",
"cy:open": "cypress open",
"test": "run-p --race dev cy:run",
"deploy-prod": "firebase deploy --debug --token \"$FIREBASE_TOKEN\" --only hosting",
"deploy-dev": "firebase deploy --debug --only hosting --project jointcreative1-dev"
},
"dependencies": {
"#fullhuman/postcss-purgecss": "^2.1.2",
"#rollup/plugin-json": "^4.0.3",
"compression": "^1.7.4",
"connect-redis": "^4.0.4",
"cssnano": "^4.1.10",
"express": "^4.17.1",
"express-session": "^1.17.1",
"firebase": "^7.14.2",
"postcss-load-config": "^2.1.0",
"redis": "^3.0.2",
"session-file-store": "^1.4.0",
"sirv": "^0.4.2"
},
"devDependencies": {
"#babel/core": "^7.9.0",
"#babel/plugin-syntax-dynamic-import": "^7.8.3",
"#babel/plugin-transform-runtime": "^7.9.0",
"#babel/preset-env": "^7.9.0",
"#babel/runtime": "^7.9.2",
"#rollup/plugin-commonjs": "^11.0.2",
"#rollup/plugin-node-resolve": "^7.1.3",
"#rollup/plugin-replace": "^2.3.1",
"#rollup/pluginutils": "^3.0.9",
"firebase-tools": "^7.16.2",
"npm-run-all": "^4.1.5",
"postcss": "^7.0.27",
"postcss-cli": "^7.1.0",
"rollup": "^1.32.1",
"rollup-plugin-babel": "^4.4.0",
"rollup-plugin-node-resolve": "^5.2.0",
"rollup-plugin-svelte": "^5.2.1",
"rollup-plugin-terser": "^5.3.0",
"sapper": "^0.27.12",
"svelte": "^3.21.0",
"svelte-preprocess": "^3.7.4",
"tailwindcss": "^1.3.5"
}
Postcss.config
const tailwindcss = require("tailwindcss");
const cssnano = require("cssnano")({
preset: "default"
});
const purgecss = require("#fullhuman/postcss-purgecss")({
content: ["./src/**/*.svelte", "./src/**/*.html"],
defaultExtractor: content => content.match(/[A-Za-z0-9-_:/]+/g) || []
});
module.exports = {
plugins: [
tailwindcss("./tailwind.config.js"),
...(process.env.NODE_ENV === "production"
? [purgecss, cssnano]
: [])
]
};
rollup.config
export default {
client: {
input: config.client.input(),
output: config.client.output(),
plugins: [
replace({
'process.browser': true,
'process.env.NODE_ENV': JSON.stringify(mode),
}),
svelte({
dev,
hydratable: true,
emitCss: true,
preprocess: sveltePreprocess({ postcss: true }),
}),
resolve({
browser: true,
dedupe: ['svelte'],
}),
commonjs(),
legacy &&
babel({
extensions: ['.js', '.mjs', '.html', '.svelte'],
runtimeHelpers: true,
exclude: ['node_modules/#babel/**'],
presets: [
[
'#babel/preset-env',
{
targets: '> 0.25%, not dead',
},
],
],
plugins: [
'#babel/plugin-syntax-dynamic-import',
[
'#babel/plugin-transform-runtime',
{
useESModules: true,
},
],
],
}),
!dev &&
terser({
module: true,
}),
],
onwarn,
},
server: {
input: config.server.input(),
output: config.server.output(),
plugins: [
replace({
'process.browser': false,
'process.env.NODE_ENV': JSON.stringify(mode),
}),
svelte({
generate: 'ssr',
dev,
preprocess: sveltePreprocess({ postcss: true })
}),
resolve({
dedupe: ['svelte'],
}),
commonjs(),
],
external: Object.keys(pkg.dependencies).concat(
require('module').builtinModules ||
Object.keys(process.binding('natives'))
),
onwarn,
},
serviceworker: {
input: config.serviceworker.input(),
output: config.serviceworker.output(),
plugins: [
resolve(),
replace({
'process.browser': true,
'process.env.NODE_ENV': JSON.stringify(mode),
}),
commonjs(),
!dev && terser(),
],
onwarn,
},
};

Related

Vuetify design is broken when deployed on Heroku

Assumption
I am building a service with docker and Nuxt.js.. I am using Vuetyify for the user interface, but when deployed to Heroku, the CSS design is broken. Specifically, the alert width is not applied, there are blank spaces in the alert area, and other strange behavior. It works fine in the development environment. I have looked into it, but all I found is that the CSS loads differently in the development environment than in the production environment.
Is there any solution to this problem?
What we want to solve
I want to solve Vuetify design collapse on Heroku.
Code
package.json
{
"name": "app",
"version": "1.0.0",
"private": true,
"scripts": {
"dev": "nuxt",
"build": "nuxt build",
"start": "nuxt start",
"export": "nuxt export",
"serve": "nuxt serve",
"generate": "nuxt generate",
"lint:js": "eslint --ext \".js,.vue\" --ignore-path .gitignore .",
"lint": "yarn lint:js",
"test": "jest"
},
"dependencies": {
"#nuxtjs/auth": "^4.9.1",
"#nuxtjs/axios": "^5.13.6",
"#vue/test-utils": "^1.3.0",
"babel-core": "^7.0.0-bridge.0",
"babel-jest": "^27.4.6",
"core-js": "^3.9.1",
"jest": "^27.4.7",
"moment": "^2.29.1",
"nuxt": "^2.15.3",
"vue-jest": "^3.0.7"
},
"devDependencies": {
"#babel/core": "^7.16.12",
"#babel/preset-env": "^7.16.11",
"#nuxtjs/eslint-config": "^6.0.0",
"#nuxtjs/eslint-module": "^3.0.2",
"#nuxtjs/vuetify": "^1.11.3",
"babel-eslint": "^10.1.0",
"eslint": "^7.22.0",
"eslint-plugin-nuxt": "^2.0.0",
"eslint-plugin-vue": "^7.7.0"
}
}
nuxt.config.js
export default {
// Disable server-side rendering: https://go.nuxtjs.dev/ssr-mode
ssr: false,
publicRuntimeConfig: {
APP_NAME: process.env.APP_NAME,
BOOK_URL: process.env.BOOK_URL,
AXIOS_POST: process.env.AXIOS_POST
},
// Global page headers: https://go.nuxtjs.dev/config-head
head: {
title: 'KOUDOKU',
htmlAttrs: {
lang: 'ja'
},
meta: [
{ charset: 'utf-8' },
{ name: 'viewport', content: 'width=device-width, initial-scale=1' },
{ hid: 'description', name: 'description', content: '' }
],
link: [
{ rel: 'icon', type: 'image/x-icon', href: '/favicon.ico' }
]
},
// Global CSS: https://go.nuxtjs.dev/config-css
css: [
],
// Plugins to run before rendering page: https://go.nuxtjs.dev/config-plugins
・
・
・
// Auto import components: https://go.nuxtjs.dev/config-components
components: true,
// Modules for dev and build (recommended): https://go.nuxtjs.dev/config-modules
buildModules: [
// https://go.nuxtjs.dev/eslint
'#nuxtjs/eslint-module',
// Doc: https://www.npmjs.com/package/#nuxtjs/vuetify
'#nuxtjs/vuetify'
],
moment: {
locales: ['ja']
},
// Modules: https://go.nuxtjs.dev/config-modules
modules: [
// https://go.nuxtjs.dev/axios
'#nuxtjs/axios',
'#nuxtjs/auth'
],
// Axios module configuration: https://go.nuxtjs.dev/config-axios
・
・
・
// Added for anti-styling
// Build Configuration: https://go.nuxtjs.dev/config-build
build: {
extractCSS: true,
optimization: {
splitChunks: {
cacheGroups: {
styles: {
name: 'styles',
test: /\.(css|scss)$/,
chunks: 'initial',
enforce: true
},
components: {
name: 'components',
test: /app\/components/,
chunks: 'all',
enforce: true
}
}
}
}
},
router: {
middleware: ['auth']
}
}
heroku.yml
setup:
config:
NODE_ENV: production
NPM_CONFIG_PRODUCTION: false
build:
docker:
web: Dockerfile
config:
WORKDIR: app
API_URL: "https://book-app-api-v1.herokuapp.com"
run:
web: yarn run start

sass-loader doesn't generate css

I tried to update this webpack config to generate css from scss. I added styles.scss into src folder with one css rule:
body{
font-size: 38px;
}
If I run yarn build or yarn dev, webpack doesn't generate any css files and I don't get any error.
webpack.config.js
/* global __dirname, require, module*/
const webpack = require('webpack');
const path = require('path');
const env = require('yargs').argv.env; // use --env with webpack 2
const pkg = require('./package.json');
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
let libraryName = pkg.name;
let outputFile, mode;
if (env === 'build') {
mode = 'production';
outputFile = libraryName + '.min.js';
} else {
mode = 'development';
outputFile = libraryName + '.js';
}
const config = {
mode: mode,
entry: __dirname + '/src/index.js',
devtool: 'inline-source-map',
output: {
path: __dirname + '/lib',
filename: outputFile,
library: libraryName,
libraryTarget: 'umd',
umdNamedDefine: true,
globalObject: "typeof self !== 'undefined' ? self : this"
},
module: {
rules: [
{
test: /(\.jsx|\.js)$/,
loader: 'babel-loader',
exclude: /(node_modules|bower_components)/
},
{
test: /(\.jsx|\.js)$/,
loader: 'eslint-loader',
exclude: /node_modules/
},
{
test: /\.scss$/,
use: [
// fallback to style-loader in development
process.env.NODE_ENV !== 'production' ? 'style-loader' : MiniCssExtractPlugin.loader,
"css-loader",
"sass-loader"
]
}
]
},
resolve: {
modules: [path.resolve('./node_modules'), path.resolve('./src')],
extensions: ['.json', '.js', '.scss']
},
plugins: [
new MiniCssExtractPlugin({
// Options similar to the same options in webpackOptions.output
// both options are optional
filename: "[name].css",
chunkFilename: "[id].css"
})
]
};
module.exports = config;
package.json
{
"name": "webpack-library-starter",
"version": "1.0.2",
"description": "Produce universal library with webpack and es6",
"main": "lib/webpack-library-starter.js",
"scripts": {
"build": "webpack --env dev && webpack --env build && npm run test",
"dev": "webpack --progress --colors --watch --env dev",
"test": "mocha --require babel-register --colors ./test/*.spec.js",
"test:watch": "mocha --require babel-register --colors -w ./test/*.spec.js",
"test:cover": "cross-env NODE_ENV=test nyc mocha --require babel-register --colors test/*.js",
"repl": "node -i -e \"$(< ./lib/webpack-library-starter.js)\""
},
"repository": {
"type": "git",
"url": "https://github.com/krasimir/webpack-library-starter.git"
},
"keywords": [
"webpack",
"es6",
"starter",
"library",
"universal",
"umd",
"commonjs"
],
"author": "Krasimir Tsonev",
"license": "MIT",
"bugs": {
"url": "https://github.com/krasimir/webpack-library-starter/issues"
},
"homepage": "https://github.com/krasimir/webpack-library-starter",
"devDependencies": {
"#babel/cli": "^7.0.0-beta.51",
"#babel/core": "^7.0.0-beta.51",
"#babel/preset-env": "^7.0.0-beta.51",
"babel-eslint": "^8.0.3",
"babel-loader": "^8.0.0-beta.4",
"babel-plugin-add-module-exports": "^0.2.1",
"babel-plugin-istanbul": "^5.1.0",
"babel-preset-env": "^7.0.0-beta.3",
"babel-register": "^7.0.0-beta.3",
"chai": "^4.1.2",
"cross-env": "^5.2.0",
"eslint": "^5.0.1",
"eslint-loader": "^2.0.0",
"jsdom": "11.11.0",
"jsdom-global": "3.0.2",
"mocha": "^4.0.1",
"nyc": "^13.1.0",
"uglifyjs-webpack-plugin": "^1.2.7",
"webpack": "^4.12.2",
"webpack-cli": "^3.0.8",
"yargs": "^10.0.3"
},
"nyc": {
"sourceMap": false,
"instrument": false
},
"dependencies": {
"css-loader": "^2.1.1",
"mini-css-extract-plugin": "^0.7.0",
"sass-loader": "^7.1.0",
"style-loader": "^0.23.1"
}
}
Check, if you imported scss file in entry js file, for example index.js.

Encore, Vue, Eslint - Use the latest vue-eslint-parser

Hi guys I'm having an issue with vue-eslint-parser. I'm trying to run it on Encore
/var/app/assets/js/app.js
1:1 error Use the latest vue-eslint-parser. See also https://github.com/vuejs/eslint-plugin-vue#what-is-the-use-the-latest-vue-eslint-parser-error vue/valid-v-pre
1:1 error Use the latest vue-eslint-parser. See also https://github.com/vuejs/eslint-plugin-vue#what-is-the-use-the-latest-vue-eslint-parser-error vue/no-duplicate-attributes
1:1 error Use the latest vue-eslint-parser. See also https://github.com/vuejs/eslint-plugin-vue#what-is-the-use-the-latest-vue-eslint-parser-error vue/no-textarea-mustache
Can't figure out what's going on, link in an error doesn't help
I'm running yarn in docker container
docker-compose.yaml file
yarn:
image: node:10
command: yarn run install_watch
working_dir: /var/app
volumes:
- .:/var/app/:cached
environment:
NPM_TOKEN: "${NPM_TOKEN}"
webpack.config.js
var Encore = require('#symfony/webpack-encore');
Encore
.setOutputPath('public/build/')
.setPublicPath('/build')
.addEntry('app', './assets/js/app.js')
.enableSingleRuntimeChunk()
.cleanupOutputBeforeBuild()
.enableBuildNotifications()
.enableSourceMaps(!Encore.isProduction())
.enableEslintLoader()
.enableSassLoader()
.enableVueLoader()
;
module.exports = Encore.getWebpackConfig();
package.json
{
"devDependencies": {
"#symfony/webpack-encore": "^0.22.0",
"#vue/cli-plugin-eslint": "^3.4.1",
"babel-eslint": "^8.2.1",
"eslint-loader": "^1.9.0",
"node-sass": "^4.11.0",
"sass-loader": "^7.0.1",
"vue": "^2.6.6",
"vuex": "^3.1.0",
"vue-loader": "^15.0.11",
"vue-router": "^3.0.2",
"vue-template-compiler": "^2.6.6",
"webpack-notifier": "^1.6.0"
},
"license": "UNLICENSED",
"private": true,
"scripts": {
"dev-server": "encore dev-server",
"dev": "encore dev",
"watch": "encore dev --watch",
"build": "encore production --progress",
"install_prod": "yarn install && yarn run build",
"install_watch": "yarn install && yarn run watch"
}
}
.eslintrc.json
{
"env": {
"browser": true,
"es6": true
},
"extends": [
"eslint:recommended",
"plugin:vue/recommended"
],
"globals": {
"Atomics": "readonly",
"SharedArrayBuffer": "readonly"
},
"parserOptions": {
"parser": "babel-eslint",
"ecmaVersion": 2018,
"sourceType": "module"
},
"plugins": [
"vue"
],
"rules": {
}
}
Seems like there is a conflict between "parser": "babel-eslint" and the Vue plugin.
Source : https://github.com/vuejs/eslint-plugin-vue/issues/30
Solution described here : The workaround is here: https://github.com/mysticatea/vue-eslint-parser#-options
"parserOptions": {"parser": "babel-eslint"} should work.
Here is a complete working .eslintrc.js file (at least on my project):
module.exports = {
// Use only this configuration
root: true,
// File parser
parser: 'vue-eslint-parser',
parserOptions: {
// Use babel-eslint for JavaScript
'parser': 'babel-eslint',
'ecmaVersion': 2017,
// With import/export syntax
'sourceType': 'module'
},
// Environment global objects
env: {
browser: true,
es6: true,
},
extends: [
// https://github.com/feross/standard/blob/master/RULES.md#javascript-standard-style
'standard',
// https://github.com/vuejs/eslint-plugin-vue#bulb-rules
'plugin:vue/recommended',
]
,}

Docker build image - glob error { Error: EPERM: operation not permitted, scandir

I'm attempting to build a Docker image of a React+TypeScript+NodeJS application built with Webpack 2.0, but I get the following error
> frontend#0.0.1 build /
> webpack -p --config configs/webpack.config.ts --env.build --env.sourceMap
{ isDev: false }
glob error { Error: EPERM: operation not permitted, scandir '/proc/1/map_files/55836c87b000-55836c897000'
errno: -1,
code: 'EPERM',
syscall: 'scandir',
path: '/proc/1/map_files/55836c87b000-55836c897000' }
Error: EPERM: operation not permitted, scandir '/proc/1/map_files/55836c87b000-55836c897000'
after running the following command
docker build -t frontend .
My package.json looks like this
"scripts": {
"clean": "rimraf build",
"build": "webpack -p --config configs/webpack.config.ts --env.build --env.sourceMap",
"dev": "webpack-dev-server --config configs/webpack.config.ts",
"dev:open": "webpack-dev-server --config configs/webpack.config.ts --open",
"lint": "tslint --project tsconfig.json && echo \"running stylelint\" &&./node_modules/stylelint/bin/stylelint.js \"src/**/*.scss\"",
"tsc": "tsc -p .",
"tsc:watch": "tsc -p . --noEmit -w",
"test": "jest --config jest.json",
"reinstall": "rm -rf node_modules && npm install",
"precommit": "npm run lint",
"prepush": "npm run lint & npm run tsc & npm run test",
"organize": "npm prune && npm dedupe && npm shrinkwrap --dev",
"deploy": "npm run build && npm run serve",
"serve": "NODE_ENV=production node server.ts"
},
"optionalDependencies": {
"fsevents": "*"
},
"dependencies": {
"#types/node": "^8.0.51",
"#types/prop-types": "^15.5.2",
"#types/react": "^16.0.22",
"#types/react-dom": "^16.0.3",
"#types/react-hot-loader": "^3.0.5",
"#types/react-redux": "^5.0.12",
"#types/react-router-dom": "^4.2.1",
"#types/react-router-redux": "^5.0.10",
"#types/redux": "^3.6.31",
"#types/webpack": "^3.8.1",
"#types/webpack-dev-server": "^2.9.2",
"#types/webpack-env": "^1.13.2",
"awesome-typescript-loader": "^3.3.0",
"axios": "^0.17.1",
"babel-core": "^6.26.0",
"babel-loader": "^7.1.2",
"babel-preset-env": "^1.6.1",
"css-loader": "^0.28.7",
"express": "^4.16.2",
"extract-text-webpack-plugin": "^3.0.2",
"file-loader": "^1.1.5",
"history": "^4.7.2",
"html-webpack-plugin": "^2.30.1",
"image-webpack-loader": "^3.4.2",
"morgan": "^1.9.0",
"node-sass": "^4.6.1",
"react": "^16.1.0",
"react-dom": "^16.1.0",
"react-redux": "^5.0.6",
"react-router-dom": "^4.2.2",
"react-router-redux": "^4.0.8",
"redux": "^3.7.2",
"redux-thunk": "^2.2.0",
"rimraf": "^2.6.2",
"sass-loader": "^6.0.6",
"style-loader": "^0.19.0",
"stylelint": "^8.2.0",
"stylelint-config-standard": "^17.0.0",
"stylelint-webpack-plugin": "^0.9.0",
"ts-loader": "^3.1.1",
"ts-node": "^3.3.0",
"tslib": "^1.8.0",
"tslint": "^5.8.0",
"tslint-react": "^3.2.0",
"typescript": "^2.6.1",
"webpack": "^3.8.1"
},
"devDependencies": {
"#types/chai": "^4.0.4",
"#types/chai-as-promised": "7.1.0",
"#types/enzyme": "^3.1.4",
"#types/jest": "^21.1.6",
"babel-jest": "^21.2.0",
"webpack-dev-server": "^2.9.4",
"enzyme": "^3.1.1",
"husky": "^0.14.3",
"jest": "^21.2.1",
"jest-cli": "^21.2.1",
"react-test-renderer": "^16.1.0",
"ts-jest": "^21.2.1"
}
and my webpack.config.ts looks like this
const filePath = require('path');
const webpack = require('webpack');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const ExtractTextPlugin = require("extract-text-webpack-plugin");
const StyleLintPlugin = require('stylelint-webpack-plugin');
const PATHS = {
root: filePath.resolve(__dirname, '..'),
nodeModules: filePath.resolve(__dirname, '../node_modules'),
src: filePath.resolve(__dirname, '../src'),
build: filePath.resolve(__dirname, '../build'),
style: filePath.resolve(__dirname, '../src/style'),
images: filePath.resolve(__dirname, '../src/images')
};
const DEV_SERVER = {
historyApiFallback: true,
overlay: true,
stats: {
providedExports: false,
chunks: false,
hash: false,
version: false,
modules: false,
reasons: false,
children: false,
source: false,
errors: true,
errorDetails: true,
warnings: false,
publicPath: false
}
};
interface env {
build?: string;
sourceMap?: string;
awesome?: string;
}
module.exports = (env: env = {}) => {
const isBuild = !!env.build;
const isDev = !env.build;
const isSourceMap = !!env.sourceMap || isDev;
console.log({ isDev });
return {
cache: true,
devtool: isDev ? 'eval-source-map' : 'source-map',
devServer: DEV_SERVER,
context: PATHS.root,
entry: {
app: [
'./src/index.tsx',
],
},
output: {
path: PATHS.build,
filename: isDev ? '[name].js' : '[name].[hash].js',
publicPath: '/',
},
resolve: {
extensions: ['.ts', '.tsx', '.js', '.jsx', '.json'],
modules: ['src', 'node_modules'],
},
module: {
rules: [
{
test: /\.tsx?$/,
include: PATHS.src,
loader: (env.awesome ?
[
{
loader: 'awesome-typescript-loader',
options: {
transpileOnly: true,
useTranspileModule: false,
sourceMap: isSourceMap,
},
},
] : [
{
loader: 'ts-loader',
options: {
transpileOnly: true,
compilerOptions: {
'sourceMap': isSourceMap,
'target': isDev ? 'es2015' : 'es5',
'isolatedModules': true,
'noEmitOnError': false,
},
},
},
]
),
},
{
test: /\.js$/,
exclude: /(node_modules|bower_components)/,
use: {
loader: 'babel-loader',
options: {
presets: ['env']
}
}
},
{
test: /\.json$/,
include: [PATHS.src],
loader: { loader: 'json-loader' },
},
{
test: /\.css$/,
loader: ExtractTextPlugin.extract({
use: 'css-loader'
})
},
{
test: /\.scss$/,
loader: ExtractTextPlugin.extract({
fallback: "style-loader",
use: "css-loader!sass-loader",
}),
},
{
test: /\.(jpe?g|png|gif|svg|ico)$/i,
loaders: [
'file-loader?hash=sha512&limit=1000&digest=hex&name=[hash].[ext]',
'image-webpack-loader?bypassOnDebug&optipng.optimizationLevel=7&gifsicle.interlaced=false'
]
}
],
},
plugins: [
StyleLintPlugin(),
new ExtractTextPlugin('style.css'),
new webpack.DefinePlugin({
'process.env': {
NODE_ENV: JSON.stringify(isDev ? 'development' : 'production'),
},
}),
new webpack.optimize.CommonsChunkPlugin({
name: 'vendor',
minChunks: (module: any) => module.context && module.context.indexOf('node_modules') !== -1,
}),
new webpack.optimize.CommonsChunkPlugin({
name: 'manifest',
}),
...(isDev ? [
new webpack.NamedModulesPlugin(),
] : []),
...(isBuild ? [
new webpack.LoaderOptionsPlugin({
minimize: true,
debug: false
}),
new webpack.optimize.UglifyJsPlugin({
beautify: false,
compress: {
screw_ie8: true,
warnings: false
},
comments: false,
sourceMap: isSourceMap,
}),
new HtmlWebpackPlugin({
template: './index.html',
}),
] : []),
],
stats: {
providedExports: false,
chunks: false,
hash: false,
version: false,
timings: false,
modules: false,
reasons: true,
children: false,
source: false,
warnings: true,
publicPath: false
},
performance: {
hints: "warning"
}
};
};
and my Dockerfile looks like this
FROM node:latest
COPY package.json package.json
COPY npm-shrinkwrap.json npm-shrinkwrap.json
RUN npm install --production
COPY . .
EXPOSE 8080
RUN npm run deploy
and finally I have a .dockerignore
Dockerfile
.dockerignore
.gitignore
README.md
build
node_modules
As far as I can tell this is a permissions issue. Is there something I can do to change permissions? I'm not even sure what process fails.
The map_files directory is a representation of the files a process currently has memory mapped by the kernel. This info is also contained in the maps file in the same directory.
As these files are a representation of memory, they change frequently. If a process creates a directory listing and then processes the list, the files might not exist by the time the process gets to them.
If the build is reporting files in /proc, a search has likely started from the / directory in the container and is recursively searching everything on the filesystem.
Use a directory other than / as the WORKDIR in your Dockerfile
FROM node:latest
WORKDIR /app
COPY package.json /app/package.json
COPY npm-shrinkwrap.json /app/npm-shrinkwrap.json
RUN npm install --production
COPY . /app/
EXPOSE 8080
RUN npm run deploy
This can also get this exact error if you accidentally hit Deny when OSX asks if you want to allow Docker to update files on your computer. For some reason, factory resetting docker and uninstalling/re-installing does not cause the prompt for these permissions to appear again.
I was able to fix the error by following these steps to grant Docker permissions to Documents where my code was stored.

Webpack --watch doesn't trigger for CSS files in specific directory

Using webpack --watch, changes to .pcss (PostCSS) files are not picked up when within [src/components/Main/]. Changes to .js files are picked up fine as well as .pcss files in other directories. Because my web app is isomorphic, ExtractTextPlugin is used to squish all the CSS together and push it into a single file.
Full code on GitHub.
This is on macOS 10.12.X.
webpack.config.js:
const path = require('path')
const webpack = require('webpack')
const ExtractTextPlugin = require('extract-text-webpack-plugin')
const babelPresetEnvExclude = require('./config/babel-preset-env.exclude')
const babelPluginRelay = ['relay', { schema: 'data/schema.graphqls', }]
const styleRules = {
test: /\.p?css$/,
exclude: /node_modules/,
use: ExtractTextPlugin.extract({
fallback: 'style-loader',
use: [
{
loader: 'css-loader',
options: { importLoaders: 1 },
},
'postcss-loader',
],
}),
}
const fileRules = {
test: /\.((pn|sv|jpe?)g|gif)$/,
use: ['file-loader'],
}
const server = {
target: 'node',
entry: './build/unbundled/server.js',
output: {
filename: 'server.js',
path: path.resolve(__dirname, 'build')
},
resolve: {
extensions: ['.js', '.jsx'],
},
module: {
rules: [
{
test: /\.jsx?$/,
exclude: /(node_modules|bower_components)/,
use: [{
loader: 'babel-loader',
options: {
plugins: [babelPluginRelay],
},
}],
},
styleRules,
fileRules,
]
},
devtool: 'source-map',
plugins: [
new webpack.DefinePlugin({
'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV || 'development')
}),
// Overwrites the same file created by the browser webpack config. A loader
// needs to be specified to take care of the import statements and it wont
// work without also outputting a file. There has to be a better way to
// handle this, but I want to focus on other parts for now.
// #todo: make this less bad.
new ExtractTextPlugin('public/main.css'),
]
}
const browser = {
target: 'web',
entry: './build/unbundled/browser.js',
output: {
filename: 'bundle.js',
path: path.resolve(__dirname, 'build/public')
},
resolve: {
extensions: ['.js', '.jsx'],
},
module: {
rules: [
{
test: /\.jsx?$/,
exclude: /(node_modules|bower_components)/,
use: [{
loader: 'babel-loader',
options: {
presets: [
['env', {
debug: true,
useBuiltIns: true,
targets: { browsers: ['last 2 versions'] },
exclude: babelPresetEnvExclude
}]
],
plugins: [babelPluginRelay],
},
}],
},
styleRules,
fileRules,
]
},
devtool: 'source-map',
plugins: [
new webpack.DefinePlugin({
'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV || 'development')
}),
new ExtractTextPlugin('main.css'),
]
}
console.log('NODE_ENV', JSON.stringify(process.env.NODE_ENV || 'development'))
module.exports = [browser, server]
package.json:
{
"name": "rtm-owl",
"version": "1.0.0",
"main": "index.js",
"author": "boring#example.com",
"license": "MIT",
"scripts": {
"relay": "relay-compiler --src ./build/unbundled --schema data/schema.graphqls",
"build": "tsc --pretty && npm run relay && webpack --progress",
"debug": "npm run build && node --inspect build/server.js",
"debug-brk": "npm run build && node --inspect-brk build/server.js",
"start": "node build/server.js",
"watch": "concurrently --kill-others 'tsc --pretty --watch' 'relay-compiler --src ./build/unbundled --schema data/schema.graphqls --watch' 'webpack --watch' 'nodemon build/server.js'"
},
"devDependencies": {
"#types/chart.js": "^2.6.1",
"#types/debug": "^0.0.30",
"#types/express": "^4.0.36",
"#types/fs-extra": "^4.0.0",
"#types/isomorphic-fetch": "^0.0.34",
"#types/lodash": "^4.14.71",
"#types/morgan": "^1.7.32",
"#types/react": "^16.0.0",
"#types/react-chartjs-2": "^2.0.2",
"#types/react-dom": "^15.5.1",
"#types/react-redux": "^4.4.47",
"#types/serialize-javascript": "^1.3.1",
"autoprefixer": "^7.1.2",
"babel-core": "^6.25.0",
"babel-loader": "^7.1.1",
"babel-plugin-relay": "^1.1.0",
"babel-polyfill": "^6.23.0",
"babel-preset-env": "^1.6.0",
"concurrently": "^3.5.0",
"css-loader": "^0.28.4",
"extract-text-webpack-plugin": "^3.0.0",
"file-loader": "^0.11.2",
"fs-extra": "^4.0.0",
"isomorphic-fetch": "^2.2.1",
"nodemon": "^1.11.0",
"postcss-css-variables": "^0.7.0",
"postcss-import": "^10.0.0",
"postcss-loader": "^2.0.6",
"postcss-nested": "^2.1.0",
"relay-compiler": "^1.1.0",
"relay-runtime": "^1.1.0",
"serialize-javascript": "^1.3.0",
"style-loader": "^0.18.2",
"typescript": "^2.4.1",
"webpack": "^3.0.0"
},
"dependencies": {
"chart.js": "^2.6.0",
"debug": "^2.6.8",
"express": "^4.15.3",
"farce": "^0.2.1",
"found": "^0.3.1",
"found-relay": "^0.3.0-alpha.4",
"lodash": "^4.17.4",
"morgan": "^1.8.2",
"react": "^15.6.1",
"react-chartjs-2": "^2.5.5",
"react-dom": "^15.6.1",
"react-redux": "^5.0.5",
"react-relay": "^1.0.0",
"redux": "^3.7.2"
}
}
I encountered similar behaviour, webpack --watch does not react to changes in css files on macOS 10.14. I used the basic style-loader and css-loader and require my css files like require('./style.css').
Solved by switching to nodemon. In my package.json the following setup runs webpack whenever js or css files become modified.
...
scripts: {
"build": "webpack",
"watchbuild": "nodemon --watch ./ --ext js,css --ignore dist --exec \"npm run build\"",
...
},
devDependencies: {
"nodemon": "^2.0.4",
"webpack": "^4.39.3",
...
}
...
The setup can be easily customized to watch more file types and to execute a series of commands. For example nodemon --watch ./ --ext js,ejs,css,pcss --ignore dist --exec 'npm run lint && npm run build' will also watch ejs templates and pcss styles and run linter before build.
Note that I had to ignore my build directory dist to prevent infinite build loop. Note also \" instead of ' to provide compatibility between macOS and Windows.

Resources