ABOUT ME

-

Today
-
Yesterday
-
Total
-
  • webpack , scss, config파일 설정
    Share/Nodejs 2020. 11. 22. 23:31

     

     

    npm i webpack webpack_cli 

     

    package 파일 런 수정 

     

     

     

    scsss 파일 읽기 문제 

    npm i extract-text-webpack-plugin

     

    scss-> css  = css loader필요 

    npm i css-loader postcss-loader sass-loader

     

     

     

    postCss 

    npm i autoprefixer 

    추가 plugin 설치 필요 (-.-) 

     

    npm i node-sass 

     

     

    버전 dependency가....와..........젠장.

     

     

     

    webpack.config.js

    const path = require("path");
    const autoprefixer = require("autoprefixer");
    const MiniCssExtractPlugin = require('mini-css-extract-plugin');
    const MODE = process.env.WEBPACK_ENV;
    const ENTRY_FILE = path.resolve(__dirname, "assets", "js", "main.js");
    const OUTPUT_DIR = path.join(__dirname, "static");
    
    
    const config = {
      entry: ["@babel/polyfill", ENTRY_FILE],
      mode: MODE,
      module: {
        rules: [
          {
            test: /\.(scss)$/,
            use: [
              {
                loader: MiniCssExtractPlugin.loader
              },
              {
                loader: "css-loader"
              },
              {
                loader: "postcss-loader",
                options: {
                  postcssOptions: {
                    plugins: [
                      [
                        'autoprefixer',
                        {
                          //options
                          browsers: "cover 99.5%"
                        },
                      ]
                    ]
                  }
                }
              },
              {
                loader: "sass-loader"
              }
            ]
          }
        ]
      },
      output: {
        path: OUTPUT_DIR,
        filename: "[name].js"
      },
      plugins: [
        new MiniCssExtractPlugin({
          // Options similar to the same options in webpackOptions.output
          // both options are optional
          filename: '[name].css'
        }),
      ]
    };
    
    module.exports = config;

     

    package.json

    {
      "name": "toyproject_youtube",
      "version": "1.0.0",
      "scripts": {
        "dev:server": "nodemon --exec babel-node init.js --delay 2",
        "dev:assets": "cross-env WEBPACK_ENV=development webpack -w",
        "build:assets": "cross-env WEBPACK_ENV=production webpack"
      },
      "author": "",
      "license": "ISC",
      "dependencies": {
        "@babel/core": "^7.12.3",
        "@babel/node": "^7.12.6",
        "@babel/polyfill": "^7.12.1",
        "@babel/preset-env": "^7.12.1",
        "@fortawesome/fontawesome-free": "^5.15.1",
        "autoprefixer": "^10.0.0",
        "babel-loader": "^8.2.1",
        "body-parser": "^1.19.0",
        "cookie-parser": "^1.4.5",
        "cross-env": "^7.0.2",
        "dotenv": "^8.2.0",
        "express": "^4.17.1",
        "extract-text-webpack-plugin": "^4.0.0-beta.0",
        "helmet": "^4.2.0",
        "mongoose": "^5.10.15",
        "morgan": "^1.10.0",
        "multer": "^1.4.2",
        "node-sass": "^4.14.1",
        "nodemon": "^2.0.6",
        "postcss-loader": "^4.0.2",
        "pug": "^3.0.0",
        "webpack-cli": "^4.2.0"
      },
      "main": "app.js",
      "devDependencies": {
        "autoprefixer": "^10.0.0",
        "css-loader": "^4.3.0",
        "mini-css-extract-plugin": "^0.11.2",
        "postcss": "^8.0.5",
        "postcss-loader": "^4.0.2",
        "sass-loader": "^7.1.0",
        "webpack": "^4.36.1",
        "webpack-cli": "^3.3.12"
      },
      "repository": {
        "type": "git",
        "url": "git+https://github.com/superBaik/toyproject_youtube.git"
      },
      "bugs": {
        "url": "https://github.com/superBaik/toyproject_youtube/issues"
      },
      "homepage": "https://github.com/superBaik/toyproject_youtube#readme",
      "description": ""
    }
    

     

     

    폴더 구조 

     

     

    Run 

    - mongod

    - npm run dev:assets

    - npm run dev:server 

     

     

    'Share > Nodejs' 카테고리의 다른 글

    MacOS upgrade(Big Sur) 로 인한 Mongodb 권한 이슈  (0) 2020.12.27
    [Error] npm 글로벌 설치 관련 에러  (0) 2020.11.25
    Basic CRUD with express + mongodb  (0) 2020.11.18
    Nodejs MVC patter Setting  (0) 2020.11.16
    git 사용 요약  (0) 2020.11.16

    댓글

실험중인 삶, Life is not a race