📖 171ページ
package.json
{
"description": "...",
"repository": "...",
"scripts": {
"prod": "webpack --mode production",
"dev": "webpack --mode development -w"
},
(省略)
}
📖 171ページ
package.json
{
"description": "...",
"repository": "...",
"scripts": {
"prod": "webpack --mode production",
"dev": "webpack --mode development -w"
},
(省略)
}
📖 172ページ
webpack.config.js
module.exports = {
entry: './src/js/app.js',
}
📖 176ページ
webpack.config.js
module.exports = {
entry: './src/js/main.js',
module: {} // 追記
}
📖 176ページ
webpack.config.js
module.exports = {
entry: './src/js/main.js',
module: {
rules: [] // 追記
}
}
📖 177ページ
webpack.config.js
module.exports = {
entry: './src/js/main.js',
output: {
filename: 'bundle.js'
},
module: {
rules: [
{ // 追記
test: /.js$/, //
use: 'babel-loader' //
} //
]
}
}
📖 179ページ
webpack.config.js
module.exports = {
entry: './src/js/main.js',
output: {
filename: './dist/bundle.js'
},
module: {
rules: [
{
test: /.js$/,
use: {
loader: 'babel-loader',
options: {
presets: ['@babel/preset-env']
}
}
}
]
}
}
📖 180ページ
main.js
const babel = () => {
console.log('hello world')
}
babel()
📖 183ページ
main.js
import $ from 'jquery'
$('button').on('click', () => {
window.alert('hello webpack')
})
📖 186ページ
main.js
import $ from 'jquery'
import 'slick-carousel'
import '../../node_modules/slick-carousel/slick/slick.css'
import '../../node_modules/slick-carousel/slick/slick-theme.css'
📖 187ページ
webpack.config.js
module.exports = {
entry: './src/js/app.js',
module: {
rules: [
{
test: /.js$/,
use: {
loader: 'babel-loader',
options: {
presets: ['@babel/preset-env']
}
}
},
{
test: /.css$/,
use: ['css-loader']
}
]
}
}
📖 189ページ
webpack.config.js
module.exports = {
entry: './src/js/main.js',
module: {
rules: [
{
test: /.js$/,
use: {
loader: 'babel-loader',
options: {
presets: ['@babel/preset-env']
}
}
},
{
test: /.css$/,
use: ['style-loader', 'css-loader']
},
{
test: /.gif|png|jpg|eot|wof|woff|ttf|svg$/,
use: ['url-loader']
}
]
}
}
📖 191ページ
webpack.config.js
module.exports = {
entry: './src/js/main.js',
module: {
rules: [
{
test: /.js$/,
use: {
loader: 'babel-loader',
options: {
presets: ['@babel/preset-env']
}
}
},
{
test: /.css$/
use: ['style-loader', 'css-loader']
},
{
test: /.gif|png|jpg|eot|wof|woff|ttf|svg$/,
use: ['url-loader']
}
]
}
}