WebPackも知らないうちにv3になってたから試しかけてみたメモ。 gulp + webpackっていう構成は単体よりも後々辛そうだし・・・
- Sassのimportに従った複数ファイルコンパイル
- _*.scss も監視してくれる
- 不要(main.js)なファイルが...
- ディレクトリ内まるっと監視ができない... grob-import ?
import './style/style.scss'; |
{ | |
"name": "test-webpack3", | |
"version": "1.0.0", | |
"description": "", | |
"main": "index.js", | |
"scripts": { | |
"test": "echo \"Error: no test specified\" && exit 1", | |
"webpack": "webpack" | |
}, | |
"keywords": [], | |
"author": "", | |
"license": "ISC", | |
"devDependencies": { | |
"babel-preset-es2017": "^6.24.1", | |
"css-loader": "^0.28.7", | |
"extract-text-webpack-plugin": "^3.0.1", | |
"node-sass": "^4.5.3", | |
"sass-loader": "^6.0.6", | |
"style-loader": "^0.19.0", | |
"webpack": "^3.7.1" | |
} | |
} |
@import "_style"; | |
.hoge { | |
color: red; | |
} |
const ExtractTextPlugin = require('extract-text-webpack-plugin'); | |
// import ExtractTextPlugin from 'extract-text-webpack-plugin'; | |
module.exports = { | |
entry: './main.js', | |
output: { | |
path: `${__dirname}/`, | |
filename: 'style.css' | |
}, | |
module: { | |
rules: [ | |
{ | |
test: /\.scss/, | |
use: ExtractTextPlugin.extract({ | |
fallback: "style-loader", | |
use: ['css-loader', 'sass-loader'] | |
}) | |
}, | |
] | |
}, | |
plugins: [ | |
new ExtractTextPlugin('style.css') | |
] | |
} |